# Problems working with p5.PolySynth - reference is not clear

**URL:** https://discourse.processing.org/t/problems-working-with-p5-polysynth-reference-is-not-clear/21892
**Category:** Libraries
**Created:** [June 15, 2020, 2:59pm UTC](https://discourse.processing.org/t/problems-working-with-p5-polysynth-reference-is-not-clear/21892 "2020-06-15T14:59:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![umutreldem](https://avatars.discourse-cdn.com/v4/letter/u/e5b9ba/32.png) [@umutreldem](https://discourse.processing.org/u/umutreldem)
#### Post date: [June 15, 2020, 2:59pm UTC](https://discourse.processing.org/t/problems-working-with-p5-polysynth-reference-is-not-clear/21892/1 "2020-06-15T14:59:57Z")

</div>

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()](https://p5js.org/reference/#/p5.PolySynth/play), the function requires at least three arguments. The reference claims they are all optional.

```auto
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()](https://p5js.org/reference/#/p5.PolySynth/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.

```auto
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()](https://p5js.org/reference/#/p5.PolySynth/noteADSR) Is plain confusing: Using it before or after a note is played gives me:

```auto
p5.sound.js:12531 Uncaught TypeError: Cannot read property 'getValueAtTime' of undefined

```

This is from the code:

```auto
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?
