PolySynth
class Instrument ↳ extends Instrument<VoiceOptions<Voice>>
PolySynth handles voice creation and allocation for any instruments passed in as the second parameter. PolySynth is not a synthesizer by itself, it merely manages voices of one of the other types of synths, allowing any of the monophonic synthesizers to be polyphonic.
const synth = new Tone.PolySynth().toDestination();
// set the attributes across all the voices using 'set'
synth.set({ detune: -1200 });
// play a chord
synth.triggerAttackRelease(["C4", "E4", "A4"], 1);Constructor
Section titled “Constructor”new PolySynth(voice?: VoiceConstructor<Voice>, options?: RecursivePartial<OmitMonophonicOptions<VoiceOptions<Voice>>>)Parameters
-
voice
VoiceConstructor<Voice>optionalThe constructor of the voices
-
options
RecursivePartial<OmitMonophonicOptions<VoiceOptions<Voice>>>optionalThe options object to set the synth voice
new PolySynth(options?: Partial<PolySynthOptions<Voice>>)Parameters
- options
Partial<PolySynthOptions<Voice>>optional
Properties
Section titled “Properties”output
Section titled “output”↳ inherited from Instrument
output: OutputNodeThe output nodes. If the object is a sink, it does not have any output and this.output is undefined.
volume
Section titled “volume”↳ inherited from Instrument
volume: Param<"decibels">The volume of the output in decibels.
const amSynth = new Tone.AMSynth().toDestination();
amSynth.volume.value = -6;
amSynth.triggerAttackRelease("G#3", 0.2);activeVoices
Section titled “activeVoices”read-only
activeVoices: numberThe number of active voices.
Methods
Section titled “Methods”get(): VoiceOptions<Voice>Get the object’s attributes.
const osc = new Tone.Oscillator(); console.log(osc.get());
Returns VoiceOptions<Voice>
releaseAll()
Section titled “releaseAll()”releaseAll(time?: Time): thisTrigger the release portion of all the currently active voices immediately. Useful for silencing the synth.
Parameters
- time
Timeoptional
Returns this
set(options: RecursivePartial<VoiceOptions<Voice>>): thisSet a member/attribute of the voices
const poly = new Tone.PolySynth().toDestination();
// set all of the voices using an options object for the synth type
poly.set({
envelope: {
attack: 0.25
}
});
poly.triggerAttackRelease("Bb3", 0.2);Parameters
- options
RecursivePartial<VoiceOptions<Voice>>
Returns this
sync()
Section titled “sync()”sync(): thisSync the instrument to the Transport. All subsequent calls of triggerAttack and triggerRelease will be scheduled along the transport.
const fmSynth = new Tone.FMSynth().toDestination();
fmSynth.volume.value = -6;
fmSynth.sync();
// schedule 3 notes when the transport first starts
fmSynth.triggerAttackRelease("C4", "8n", 0);
fmSynth.triggerAttackRelease("E4", "8n", "8n");
fmSynth.triggerAttackRelease("G4", "8n", "4n");
// start the transport to hear the notes
Tone.Transport.start();Returns this
triggerAttack()
Section titled “triggerAttack()”Trigger the attack portion of the note
const synth = new Tone.PolySynth(Tone.FMSynth).toDestination(); // trigger a chord immediately with a velocity of 0.2 synth.triggerAttack(["Ab3", "C4", "F5"], Tone.now(), 0.2);
Parameters
Returns this
triggerAttackRelease()
Section titled “triggerAttackRelease()”triggerAttackRelease(notes: Frequency | Frequency[], duration: Time | Time[], time?: Time, velocity?: number): thisTrigger the attack and release after the specified duration
const poly = new Tone.PolySynth(Tone.AMSynth).toDestination(); // can pass in an array of durations as well poly.triggerAttackRelease(["Eb3", "G4", "Bb4", "D5"], [4, 3, 2, 1]);
Parameters
Returns this
triggerRelease()
Section titled “triggerRelease()”Trigger the release of the note. Unlike monophonic instruments, a note (or array of notes) needs to be passed in as the first argument.
const poly = new Tone.PolySynth(Tone.AMSynth).toDestination();
poly.triggerAttack(["Ab3", "C4", "F5"]);
// trigger the release of the given notes.
poly.triggerRelease(["Ab3", "C4"], "+1");
poly.triggerRelease("F5", "+3");Parameters
Returns this
unsync()
Section titled “unsync()”↳ inherited from Instrument
unsync(): thisUnsync the instrument from the Transport
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): PolySynthOptions<Synth<SynthOptions>>Returns all of the default options belonging to the class.
Returns PolySynthOptions<Synth<SynthOptions>>
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, immediate(), now(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()