FMSynth
class Instrument ↳ extends ModulationSynth<FMSynthOptions>
FMSynth is composed of two Tone.Synths where one Tone.Synth modulates the frequency of a second Tone.Synth. A lot of spectral content can be explored using the modulationIndex parameter. Read more about frequency modulation synthesis on Sound On Sound: Part 1, Part 2.
const fmSynth = new Tone.FMSynth().toDestination();
fmSynth.triggerAttackRelease("C5", "4n");Constructor
Section titled “Constructor”new FMSynth(options?: RecursivePartial<FMSynthOptions>)Parameters
- options
RecursivePartial<FMSynthOptions>optional
Properties
Section titled “Properties”detune
Section titled “detune”read-only ↳ inherited from ModulationSynth
detune: Signal<"cents">The detune in cents
envelope
Section titled “envelope”read-only ↳ inherited from ModulationSynth
envelope: AmplitudeEnvelopeThe carrier’s envelope
frequency
Section titled “frequency”read-only ↳ inherited from ModulationSynth
frequency: Signal<"frequency">The frequency control
harmonicity
Section titled “harmonicity”read-only ↳ inherited from ModulationSynth
harmonicity: MultiplyHarmonicity is the ratio between the two voices. A harmonicity of 1 is no change. Harmonicity = 2 means a change of an octave.
const amSynth = new Tone.AMSynth().toDestination();
// pitch the modulator an octave below oscillator
amSynth.harmonicity.value = 0.5;
amSynth.triggerAttackRelease("C5", "4n");modulation
Section titled “modulation”read-only ↳ inherited from ModulationSynth
modulation: OmniOscillator<any>The modulator’s oscillator which is applied to the amplitude of the oscillator
modulationEnvelope
Section titled “modulationEnvelope”read-only ↳ inherited from ModulationSynth
modulationEnvelope: AmplitudeEnvelopeThe modulator’s envelope
modulationIndex
Section titled “modulationIndex”read-only
modulationIndex: MultiplyThe modulation index which essentially the depth or amount of the modulation. It is the ratio of the frequency of the modulating signal (mf) to the amplitude of the modulating signal (ma) – as in ma/mf.
onsilence
Section titled “onsilence”↳ inherited from Monophonic
onsilence: onSilenceCallbackInvoked when the release has finished and the output is silent.
oscillator
Section titled “oscillator”read-only ↳ inherited from ModulationSynth
oscillator: OmniOscillator<any>The carrier’s oscillator
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.
portamento
Section titled “portamento”↳ inherited from Monophonic
portamento: numberThe glide time between notes.
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);Methods
Section titled “Methods”getLevelAtTime()
Section titled “getLevelAtTime()”↳ inherited from ModulationSynth
getLevelAtTime(time: Time): numberGet the level of the output at the given time. Measures the envelope(s) value at the time.
Parameters
-
time
TimeThe time to query the envelope value
Returns number The output level between 0-1
setNote()
Section titled “setNote()”↳ inherited from Monophonic
setNote(note: Frequency | FrequencyClass<number>, time?: Time): thisSet 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
-
note
Frequency | FrequencyClass<number>The note to change to.
-
time
TimeoptionalThe time when the note should be set.
Returns this
sync()
Section titled “sync()”↳ inherited from Instrument
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()”↳ inherited from Monophonic
triggerAttack(note: Frequency | FrequencyClass<number>, time?: Time, velocity?: number): thisTrigger 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
TimeoptionalWhen the note should start.
-
velocity
numberoptional default1The velocity determines how “loud” the note will be.
Returns this
triggerAttackRelease()
Section titled “triggerAttackRelease()”↳ inherited from Instrument
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
Returns this
triggerRelease()
Section titled “triggerRelease()”↳ inherited from Monophonic
triggerRelease(time?: Time): thisTrigger 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
TimeoptionalIf no time is given, the release happens immediately.
Returns this
unsync()
Section titled “unsync()”↳ inherited from Instrument
unsync(): thisUnsync the instrument from the Transport
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): FMSynthOptionsReturns all of the default options belonging to the class.
Returns FMSynthOptions
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()