Skip to main content

createInstrument

@zylem/game-lib


@zylem/game-lib / audio / createInstrument

Function: createInstrument()

createInstrument(Tone, def): Instrument

Defined in: packages/game-lib/src/lib/audio/instrument.ts:107

Builds the synth and effects chain for an instrument definition. The returned output is not connected anywhere; the caller routes it.

Parameters​

Tone​

__module

def​

effects?​

object[] = ...

envelope?​

\{ attack: number; decay: number; release: number; sustain: number; \} = ...

envelope.attack​

number = ...

envelope.decay​

number = ...

envelope.release​

number = ...

envelope.sustain​

number = ...

id​

string = ...

name​

string = ...

oscillator?​

"sawtooth" | "sine" | "square" | "triangle" = ...

preset​

"synth" | "polySynth" | "fmSynth" | "amSynth" | "membraneSynth" | "metalSynth" | "noiseSynth" | "pluckSynth" = InstrumentPresetSchema

volume?​

number = ...

Output trim in dB.

Returns​

Instrument