Skip to content
Tone.js

DuoSynth

class Instrument ↳ extends Monophonic<DuoSynthOptions>

DuoSynth is a monophonic synth composed of two MonoSynths run in parallel with control over the frequency ratio between the two voices and vibrato effect.

const duoSynth = new Tone.DuoSynth().toDestination();
duoSynth.triggerAttackRelease("C4", "2n");
new DuoSynth(options?: RecursivePartial<DuoSynthOptions>)

Parameters

read-only

detune: Signal<"cents">

The instrument’s detune control signal.

read-only

frequency: Signal<"frequency">

The instrument’s frequency signal.

harmonicity: Signal<"positive">

Harmonicity is the ratio between the two voices. A harmonicity of 1 is no change. Harmonicity = 2 means a change of an octave.

const duoSynth = new Tone.DuoSynth().toDestination();
duoSynth.triggerAttackRelease("C4", "2n");
// pitch voice1 an octave below voice0
duoSynth.harmonicity.value = 0.5;

↳ inherited from Instrument

input: undefined

The instrument only has an output

read-only

name: string

The name of the class

Default: "DuoSynth"

↳ inherited from Monophonic

Invoked when the release has finished and the output is silent.

↳ 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 Monophonic

portamento: number

The glide time between notes.

vibratoAmount: Param<"normalRange">

The amount of vibrato

vibratoRate: Signal<"frequency">

the vibrato frequency

read-only

voice0: MonoSynth

the first voice

read-only

voice1: MonoSynth

the second voice

↳ 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);
dispose(): this

clean up

Returns this this

getLevelAtTime(time: Time): number

Get the level of the output at the given time. Measures the envelope(s) value at the time.

Parameters

  • time Time

    The time to query the envelope value

Returns number The output level between 0-1

↳ inherited from Monophonic

setNote(note: Frequency | FrequencyClass<number>, time?: Time): this

Set the note at the given time. If no time is given, the note will set immediately.

const synth = new Tone.Synth().toDestination();
synth.triggerAttack("C4");
// change to F#6 in one quarter note from now.
synth.setNote("F#6", "+4n");

Parameters

Returns this

↳ inherited from Instrument

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

↳ inherited from Monophonic

triggerAttack(note: Frequency | FrequencyClass<number>, time?: Time, velocity?: number): this

Trigger the attack of the note optionally with a given velocity.

const synth = new Tone.Synth().toDestination();
// trigger the note a half second from now at half velocity
synth.triggerAttack("C4", "+0.5", 0.5);

Parameters

  • note Frequency | FrequencyClass<number>

    The note to trigger.

  • time Time optional

    When the note should start.

  • velocity number optional default 1

    The velocity determines how “loud” the note will be.

Returns this

↳ inherited from Instrument

triggerAttackRelease(note: Frequency, duration: Time, time?: Time, velocity?: number): this

Trigger the attack and then the release after the duration.

const synth = new Tone.Synth().toDestination();
// trigger "C4" for the duration of an 8th note
synth.triggerAttackRelease("C4", "8n");

Parameters

  • note Frequency

    The note to trigger.

  • duration Time

    How long the note should be held for before triggering the release. This value must be greater than 0.

  • time Time optional

    When the note should be triggered.

  • velocity number optional

    The velocity the note should be triggered at.

Returns this

↳ inherited from Monophonic

triggerRelease(time?: Time): this

Trigger the release portion of the envelope.

const synth = new Tone.Synth().toDestination();
synth.triggerAttack("C4");
// trigger the release a second from now
synth.triggerRelease("+1");

Parameters

  • time Time optional

    If no time is given, the release happens immediately.

Returns this

↳ inherited from Instrument

unsync(): this

Unsync the instrument from the Transport

Returns this

static

getDefaults(): DuoSynthOptions

Returns all of the default options belonging to the class.

Returns DuoSynthOptions