Reference p5.PolySynth

p5.PolySynth

An AudioVoice is used as a single voice for sound synthesis. The PolySynth class holds an array of AudioVoice, and deals with voices allocations, with setting notes to be played, and parameters to be set.

Examples

Syntax

p5.PolySynth([synthVoice], [maxVoices])

Parameters

synthVoice
Number:

A monophonic synth voice inheriting the AudioVoice class. Defaults to p5.MonoSynth

maxVoices
Number:

Number of voices, defaults to 8;

Fields

notes

An object that holds information about which notes have been played and which notes are currently being played. New notes are added as keys on the fly. While a note has been attacked, but not released, the value of the key is the audiovoice which is generating that note. When notes are released, the value of the key becomes undefined.

polyvalue

A PolySynth must have at least 1 voice, defaults to 8

AudioVoice

Monosynth that generates the sound for each note that is triggered. The p5.PolySynth defaults to using the p5.MonoSynth as its voice.

Methods

play

Play a note by triggering noteAttack and noteRelease with sustain time

noteADSR

noteADSR sets the envelope for a specific note that has just been triggered. Using this method modifies the envelope of whichever audiovoice is being used to play the desired note. The envelope should be reset before noteRelease is called in order to prevent the modified envelope from being used on other notes.

setADSR

Set the PolySynths global envelope. This method modifies the envelopes of each monosynth so that all notes are played with this envelope.

noteAttack

Trigger the Attack, and Decay portion of a MonoSynth. Similar to holding down a key on a piano, but it will hold the sustain level until you let go.

noteRelease

Trigger the Release of an AudioVoice note. This is similar to releasing the key on a piano and letting the sound fade according to the release level and release time.

connect

Connect to a p5.sound / Web Audio object.

disconnect

Disconnect all outputs

dispose

Get rid of the MonoSynth and free up its resources / memory.

Notice any errors or typos? Please let us know. Please feel free to edit lib/addons/p5.sound.js and open a pull request!

Related References