Instrument
@zylem/game-lib / audio / Instrument
Interface: Instrument
Defined in: packages/game-lib/src/lib/audio/instrument.ts:10
A playable instrument: a Tone.js synth for the preset, its effects chain, and an output node the song player routes into a track channel.
Properties
definition
readonlydefinition:object
Defined in: packages/game-lib/src/lib/audio/instrument.ts:11
effects?
optionaleffects?:object[]
envelope?
optionalenvelope?:object
envelope.attack
attack:
number
envelope.decay
decay:
number
envelope.release
release:
number
envelope.sustain
sustain:
number
id
id:
string
name
name:
string
oscillator?
optionaloscillator?:"sawtooth"|"sine"|"square"|"triangle"
preset
preset:
"synth"|"polySynth"|"fmSynth"|"amSynth"|"membraneSynth"|"metalSynth"|"noiseSynth"|"pluckSynth"=InstrumentPresetSchema
volume?
optionalvolume?:number
Output trim in dB.
output
readonlyoutput:ToneAudioNode
Defined in: packages/game-lib/src/lib/audio/instrument.ts:13
Connect this to a channel or destination.
Methods
dispose()
dispose():
void
Defined in: packages/game-lib/src/lib/audio/instrument.ts:18
Returns
void
releaseAll()
releaseAll(
time?):void
Defined in: packages/game-lib/src/lib/audio/instrument.ts:17
Silences ringing notes.
Parameters
time?
number
Returns
void
trigger()
trigger(
pitch,duration,time?,velocity?):void
Defined in: packages/game-lib/src/lib/audio/instrument.ts:15
Plays a note. time is in the Tone context clock (seconds); omit for now.
Parameters
pitch
number
duration
number
time?
number
velocity?
number
Returns
void