Yotam Mann edited this page Jul 7, 2016 · 5 revisions

Tone.js has a number of pre-built synthesizers.


All instruments have the same basic methods for triggering the attack and release of the envelopes.


triggerAttack takes the note value as the first argument. If no time value is passed in for the second argument, the attack will be triggered immediately. The third argument is the velocity of the attack. The velocity is a value between 0 and 1 which will scale the envelope's attack and sustain values.

//trigger the start of a note.

//trigger the start of a note at `time`
synth.triggerAttack("C4", time);

//trigger the start of a note at `time` with a velocity of 50%
synth.triggerAttack("C4", time, 0.5);


After the attack, the note will stay at the sustain level until triggerRelease is called.

//trigger the release portion of the envelope immediately

//trigger the release at `time`


To schedule an attack and release together, use triggerAttackRelease.

//trigger "C4" and then 1 second later trigger the release
synth.triggerAttackRelease("C4", 1);

Polyphony with Tone.PolySynth

Each of the synthesizers is monophonic, meaning it can only produce a single note at a time. Tone.PolySynth will turn any of the synthesizers into a polyphonic synthesizer by producing multiple copies of a synth and then handling the triggering of attacks and releases on those synth voices. Tone.PolySynth is not a synth by itself, but just a vessel for constructing multiple voices of any of the other synthesizer types.

The name of the synth is fed to the second argument of Tone.PolySynth to turn the monophonic voice into a polyphonic synthesizer like so:

//to make a 4 voice MonoSynth
var synth = new Tone.PolySynth(4, Tone.MonoSynth);

To set attributes of all the voices, use the set method.

	"envelope" : {
		"attack" : 0.1

Unlike the rest of the synthesizers, PolySynth's triggerRelease method needs to be called with the note you want to release.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.