【发布时间】:2021-01-06 08:01:08
【问题描述】:
我很难理解为什么会出现这个错误:
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');
}
【问题讨论】:
标签: javascript web-audio-api tone.js