Problems working with p5.PolySynth - reference is not clear

Getting into p5.PolySynth the last few days, I have noticed that there are some things in the reference that are not very clear to me:



*When calling .play(), the function requires at least three arguments. The reference claims they are all optional.

let poly;

function setup() {
  createCanvas(400, 400);
  poly = new p5.PolySynth();
}

function draw() {
  background(220);
}

function mousePressed() {
  //Will not play
  poly.play('A6', 1);
  //Will play
  poly.play('A6', 1, 0);
}








*Using .setADSR() to set a general envelope for the synth does not work as well. It seems that it takes the first two arguments as the attack and release times, and the other two arguments have no effect.

let poly;

function setup() {
  createCanvas(400, 400);
  poly = new p5.PolySynth();
  //Changing the last two arguments have no effect on the function.
  poly.setADSR(5.5, 0.1, 'cheese', -999);
}

function draw() {
  background(220);
}

function mousePressed() {
  //The attack time is affected by .setADSR's first argument, there is no decay.
  poly.noteAttack('A6', 1);
}

function mouseReleased() {
  //The release time is affected by .setADSR's second argument.
  poly.noteRelease('A6');
}








  • .noteADSR() Is plain confusing: Using it before or after a note is played gives me:
p5.sound.js:12531 Uncaught TypeError: Cannot read property 'getValueAtTime' of undefined

This is from the code:

let poly;

function setup() {
  createCanvas(400, 400);
  poly = new p5.PolySynth();
  //Gives an error.
  poly.noteADSR('A6', 3.3, 0.1, 0.1, 1.5);

}

function draw() {
  background(220);
}

function mousePressed() {
  poly.play('A6', 1);
  //This  will not work either-
  //poly.noteADSR('A6', 3.3, 0.1, 0.1, 1.5);

}

function mouseReleased() {
  poly.noteRelease('A6');
}

Looking at p5.sound, I see that the function looks at the notes object of the PolySynth, which gives the notes it is playing at the current moment. Why would I want to change the envelope of a note that is already playing? How can I set different envelopes for different notes, and then play them?