InstrumentAudioUnit

interface InstrumentAudioUnit<K extends keyof Instruments = keyof Instruments> extends AudioUnit, Sendable { sends: readonly Send[] midiEffects: readonly AnyMIDIEffect[] audioEffects: readonly AnyAudioEffect[] uuid: string label: string output: Nullable<AuxAudioUnit | GroupAudioUnit | OutputAudioUnit> volume: number panning: number mute: boolean solo: boolean index: number tracks: readonly AnyTrack[] noteTracks: readonly NoteTrack[] audioTracks: readonly AudioTrack[] valueTracks: readonly ValueTrack[] kind: 'instrument' instrument: [keyof Instruments] extends [K] ? AnyInstrument : Instruments[K] addSend(target: AuxAudioUnit | GroupAudioUnit, props?: Partial<Pick<Send, 'amount' | 'pan' | 'mode'>>): Send addMIDIEffect<K extends keyof MIDIEffects>(key: K, props?: DeepPartial<MIDIEffects[K]>, index?: number): MIDIEffects[K] addAudioEffect<K extends keyof AudioEffects>(key: K, props?: DeepPartial<AudioEffects[K]>, index?: number): AudioEffects[K] addNoteTrack(props?: Partial<Pick<Track, 'enabled'>>, index?: number): NoteTrack addAudioTrack(props?: Partial<Pick<Track, 'enabled'>>, index?: number): AudioTrack addValueTrack<T extends Automatable>(target: T, parameter: ParameterPath<T>, props?: Partial<Pick<Track, 'enabled'>>, index?: number): ValueTrack valueTrack<T extends Automatable>(target: T, parameter: ParameterPath<T>): Nullable<ValueTrack> remove(): void setInstrument<N extends keyof Instruments>(key: N, props?: DeepPartial<Instruments[N]>): Instruments[N] encodePreset(options?: PresetOptions): ArrayBuffer }

Unit hosting an instrument, created with Project.addInstrumentUnit

Type Parameters

Hierarchy


Properties

sends: readonly Send[]

readonly

Inherited from sends

All sends of this unit ordered by index

midiEffects: readonly AnyMIDIEffect[]

readonly

Inherited from midiEffects

MIDI effects ordered by index

audioEffects: readonly AnyAudioEffect[]

readonly

Inherited from audioEffects

Audio effects ordered by index

uuid: string

readonly

Inherited from uuid

Unique id

label: string

Inherited from label

Custom label

output: Nullable<AuxAudioUnit | GroupAudioUnit | OutputAudioUnit>

Inherited from output

Output routing (null = unplugged). Defaults to the primary output

volume: number

Inherited from volume

Volume in dB (-96 to 6, default 0)

panning: number

Inherited from panning

Pan (-1.0 = left, 0.0 = center, 1.0 = right)

mute: boolean

Inherited from mute

Mute

solo: boolean

Inherited from solo

Solo

index: number

readonly

Inherited from index

Position in the project (instruments first, then aux, groups, output)

tracks: readonly AnyTrack[]

readonly

Inherited from tracks

All tracks ordered by index

noteTracks: readonly NoteTrack[]

readonly

Inherited from noteTracks

Note tracks

audioTracks: readonly AudioTrack[]

readonly

Inherited from audioTracks

Audio tracks

valueTracks: readonly ValueTrack[]

readonly

Inherited from valueTracks

Automation tracks

kind: 'instrument'

readonly

Overrides kind

Always "instrument"

instrument: [keyof Instruments] extends [K] ? AnyInstrument : Instruments[K]

readonly

The instrument, an UnsupportedInstrument for instruments scripts cannot edit yet

Methods

addSend( target: AuxAudioUnit | GroupAudioUnit, props?: Partial<Pick<Send, 'amount' | 'pan' | 'mode'>>, ): Send

Inherited from addSend

Add a send to an auxiliary or group unit

Parameters

Returns

Example

CODE
const reverb = project.addAuxUnit({label: "Reverb"})
reverb.addAudioEffect("Reverb", {decay: 0.7})
synth.addSend(reverb, {amount: -12})

addMIDIEffect< K extends keyof MIDIEffects, >( key: K, props?: DeepPartial<MIDIEffects[K]>, index?: number, ): MIDIEffects[K]

Inherited from addMIDIEffect

Add a MIDI effect

Type Parameters

Parameters

  • key (K) — Effect type
  • props (DeepPartial<MIDIEffects[K]>, optional) — Initial parameter values
  • index (number, optional) — Insert position (default: end of chain)

Returns

Example

CODE
synth.addMIDIEffect("Arpeggio", {rate: 9, octaves: 2})

addAudioEffect< K extends keyof AudioEffects, >( key: K, props?: DeepPartial<AudioEffects[K]>, index?: number, ): AudioEffects[K]

Inherited from addAudioEffect

Add an audio effect

Type Parameters

Parameters

  • key (K) — Effect type
  • props (DeepPartial<AudioEffects[K]>, optional) — Initial parameter values
  • index (number, optional) — Insert position (default: end of chain)

Returns

Example

CODE
synth.addAudioEffect("Delay", {delay: 13, feedback: 0.4, wet: -9})
const composite = synth.addAudioEffect("Composite")
composite.addEntry({label: "Crushed"}).addAudioEffect("Crusher", {bits: 8})

addNoteTrack( props?: Partial<Pick<Track, 'enabled'>>, index?: number, ): NoteTrack

Inherited from addNoteTrack

Add a note track (only meaningful for note instruments)

Parameters

  • props (Partial<Pick<Track, "enabled">>, optional)
  • index (number, optional)

Returns

addAudioTrack( props?: Partial<Pick<Track, 'enabled'>>, index?: number, ): AudioTrack

Inherited from addAudioTrack

Add an audio track (only meaningful for audio instruments like Tape)

Parameters

  • props (Partial<Pick<Track, "enabled">>, optional)
  • index (number, optional)

Returns

addValueTrack< T extends Automatable, >( target: T, parameter: ParameterPath<T>, props?: Partial<Pick<Track, 'enabled'>>, index?: number, ): ValueTrack

Inherited from addValueTrack

Add an automation track for a parameter

Type Parameters

Parameters

  • target (T) — Any automatable object (this unit, a device, a send, ...)
  • parameter (ParameterPath<T>) — Parameter path, e.g. "cutoff" or "lfo.rate"
  • props (Partial<Pick<Track, "enabled">>, optional)
  • index (number, optional)

Returns

Example

CODE
const lane = synth.addValueTrack(synth.instrument, "cutoff")
lane.addRegion({duration: PPQN.Bar * 4}).addEvents([
    {position: 0, value: 0.2},
    {position: PPQN.Bar * 4, value: 0.9}
])

valueTrack< T extends Automatable, >( target: T, parameter: ParameterPath<T>, ): Nullable<ValueTrack>

Inherited from valueTrack

The automation track controlling a parameter, if any

Type Parameters

Parameters

  • target (T)
  • parameter (ParameterPath<T>)

Returns

remove(): void

Inherited from remove

Remove this unit including all its tracks and devices (the output cannot be removed)

Returns

  • void

setInstrument< N extends keyof Instruments, >( key: N, props?: DeepPartial<Instruments[N]>, ): Instruments[N]

Replace the instrument with another type (keeps effects and automation, and keeps note or audio tracks unless the new instrument takes the other input, which replaces them with one empty track)

Type Parameters

Parameters

  • key (N)
  • props (DeepPartial<Instruments[N]>, optional)

Returns

Example

CODE
const nano = synth.setInstrument("Nano", {release: 0.5})

encodePreset(options?: PresetOptions): ArrayBuffer

Encode the unit as an openDAW preset file (.odp), like Save as Preset in the studio. Without options it holds the instrument only, effects: true keeps the effects (a rack preset), timeline: true the tracks and regions

Parameters

Returns

  • ArrayBuffer

Example

CODE
await openDAW.saveFile(synth.encodePreset(), "preset.odp")