gpt4 book ai didi

javascript - Tone.js 错误 : 'Start time must be strictly greater than previous start time'

转载 作者:行者123 更新时间:2023-12-05 00:27:51 28 4
gpt4 key购买 nike

我很难理解为什么会抛出这个错误:

Debug.ts:8 Uncaught Error: Start time must be strictly greater thanprevious start time


奇怪的是,它只会在我刷新页面大约 4/5 次时向我抛出这个错误。大约有 1/5 的机会可以正常工作。这是我的代码:
let synth = new Tone.MetalSynth({
portamento: 0,
volume: -15,
envelope: {
attack: 0.001,
decay: 1.4,
release: 1,
},
harmonicity: 18.1,
modulationIndex: 12,
resonance: 1000,
octaves: 1.5,
});

synth.chain(Tone.Destination);

let notes = ['A2', 'B2', 'C3', 'D3', 'E3', 'F3', 'G#3'];
let html = '';
for (let i = 0; i < notes.length; i++) {
html += `<div class="whitenote" onmouseover="noteDown(this)" data-note="${notes[i]}"></div>`;
}

document.querySelector('.container-4').innerHTML = html;

function noteDown(el) {
let note = el.dataset.note;
synth.triggerAttackRelease(note, '16n');
}

最佳答案

我也有同样的问题。您必须添加时间。
这对我有用:

const synth = new Tone.Synth().toDestination();

melody.forEach(tune => {
const now = Tone.now()
synth.triggerAttackRelease(tune.note, tune.duration, now + tune.timing)
})
我的数据(旋律)看起来像这样:
[{ note: "E5", duration: "8n", timing: 0 },
{ note: "D#5", duration: "8n", timing: 0.25 },
{ note: "E5", duration: "8n", timing: 0.5 },
{ note: "D#5", duration: "8n", timing: 0.75 },
{ note: "E5", duration: "8n", timing: 1 },
{ note: "B4", duration: "8n", timing: 1.25 }]

关于javascript - Tone.js 错误 : 'Start time must be strictly greater than previous start time' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63971698/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com