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