我很难理解为什么我会被抛出这个错误:
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');
}发布于 2022-02-11 13:01:08
我也有同样的问题。你得加点时间。
这对我起了作用:
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 }]发布于 2021-03-11 12:54:26
我收到这个错误是因为多个声音/音符与triggerAttackRelease()同时排队。对我来说,我发现使用多个Synth实例(每个不同的声音/音符一个)是最好的方法。但是,请注意不要产生太多的Synth实例。
https://stackoverflow.com/questions/63971698
复制相似问题