Skip to content
Tone.js

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);
new PolySynth(voice?: VoiceConstructor<Voice>, options?: RecursivePartial<OmitMonophonicOptions<VoiceOptions<Voice>>>)

Parameters

new PolySynth(options?: Partial<PolySynthOptions<Voice>>)

Parameters

↳ inherited from Instrument

input: undefined

The instrument only has an output

maxPolyphony: number

The polyphony limit.

read-only

name: string

The name of the class

Default: "PolySynth"

↳ inherited from Instrument

output: OutputNode

The output nodes. If the object is a sink, it does not have any output and this.output is undefined.

↳ 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);

read-only

activeVoices: number

The number of active voices.

dispose(): this

clean up

Returns this this

get(): VoiceOptions<Voice>

Get the object’s attributes.

const osc = new Tone.Oscillator();
console.log(osc.get());

Returns VoiceOptions<Voice>

releaseAll(time?: Time): this

Trigger the release portion of all the currently active voices immediately. Useful for silencing the synth.

Parameters

  • time Time optional

Returns this

set(options: RecursivePartial<VoiceOptions<Voice>>): this

Set 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

Returns this

sync(): this

Sync 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(notes: Frequency | Frequency[], time?: Time, velocity?: number): this

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

  • notes Frequency | Frequency[]

    The notes to play. Accepts a single Frequency or an array of frequencies.

  • time Time optional

    The start time of the note.

  • velocity number optional

    The velocity of the note.

Returns this

triggerAttackRelease(notes: Frequency | Frequency[], duration: Time | Time[], time?: Time, velocity?: number): this

Trigger 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

  • notes Frequency | Frequency[]

    The notes to play. Accepts a single Frequency or an array of frequencies.

  • duration Time | Time[]

    the duration of the note

  • time Time optional

    if no time is given, defaults to now

  • velocity number optional

    the velocity of the attack (0-1)

Returns this

triggerRelease(notes: Frequency | Frequency[], time?: Time): this

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

  • notes Frequency | Frequency[]

    The notes to play. Accepts a single Frequency or an array of frequencies.

  • time Time optional

    When the release will be triggered.

Returns this

↳ inherited from Instrument

unsync(): this

Unsync the instrument from the Transport

Returns this

static

Returns all of the default options belonging to the class.

Returns PolySynthOptions<Synth<SynthOptions>>