6

I am having a hard time understanding why I am getting thrown this error:

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

The weird part is that it only throws me this error about 4/5 times I refresh the page. There is a 1/5 chance roughly that it will work with no problem. Here is my code:

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');
}
4

2 回答 2

0

由于多个声音/音符triggerAttackRelease()在同一时间排队,我收到了这个错误。对我来说,我发现使用多个 Synth 实例(每个不同的声音/音符一个)是最好的方法。但是,请注意不要生成太多 Synth 实例。

于 2021-03-11T12:54:26.387 回答
0

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

这对我有用:

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 }]
于 2022-02-11T13:01:08.877 回答