我很难理解为什么我会抛出这个错误:
Debug.ts:8 未捕获错误:启动时间必须严格大于先前的启动时间
奇怪的是,它只在我刷新页面的 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');
}
Run Code Online (Sandbox Code Playgroud)