crash when calling tone.js triggerattack or triggerrelease

24 Views Asked by At

I'm making a synth using p5js and tone.js, and i'm having an issue where it sometimes crashes with certain user inputs.

It's an intermittent problem, but multiple clicks at a certain speed will cause the sketch to crash.

I've stripped down the code to the minimum where I can still repeat the bug and I think its linked to the portamento in tone.js fm synth, and perhaps the speed at which triggerrelease releases, but i'm not sure how to fix it

here is the sketch

let bass
let nfrequency

function setup () {
  createCanvas(windowWidth, windowHeight);
  strokeWeight(5) 
  createSynth() 
}

function draw() {
  background(0);
  nfrequency = 220
  bass.setNote(nfrequency/4);
}

function mousePressed () {
 bass.triggerAttack();
}

function mouseReleased () {
 bass.triggerRelease();
}


function createSynth() { 
bass = new Tone.FMSynth({

  oscillator: {type: "sine"},

  portamento: 0.05 
});
bass.connect(Tone.Master); 
 
}

and these are the error messages that come up

TypeError: Failed to execute 'exponentialRampToValueAtTime' on 'AudioParam': The provided float value is non-finite.
    at undefined:7:37363

TypeError: Failed to execute 'setValueAtTime' on 'AudioParam': The provided float value is non-finite.
    at undefined:7:39588
0

There are 0 best solutions below