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
A monophonic synth voice inheriting the AudioVoice class. Defaults to p5.MonoSynth
Number of voices, defaults to 8;
Fields
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.
A PolySynth must have at least 1 voice, defaults to 8
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 a note by triggering noteAttack and noteRelease with sustain time
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.
Set the PolySynths global envelope. This method modifies the envelopes of each monosynth so that all notes are played with this envelope.
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.
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 to a p5.sound / Web Audio object.
Disconnect all outputs
Get rid of the MonoSynth and free up its resources / memory.