Instrument
internal class ↳ extends ToneAudioNode<Options>
Base-class for all instruments
Constructor
Section titled “Constructor”new Instrument(options?: Partial<InstrumentOptions>)Parameters
- options
Partial<InstrumentOptions>optional
Properties
Section titled “Properties”output
Section titled “output”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”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”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()”Start the instrument’s note.
Parameters
Returns this
triggerAttackRelease()
Section titled “triggerAttackRelease()”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()”triggerRelease(...args: any[]): thisTrigger the release phase of the current note.
Parameters
- args
any[]
Returns this
unsync()
Section titled “unsync()”unsync(): thisUnsync the instrument from the Transport
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): InstrumentOptionsReturns all of the default options belonging to the class.
Returns InstrumentOptions
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: name, channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()