Talos docs

AudioDirector

Since 0.6
Plain text

Signature

export class AudioDirector {
  defaultBus: AudioBus
  masterVolume: number
  constructor(ctx: Ctx, opts: AudioDirectorOptions = {})
  play(cue: Cue | string, extra: Partial<Cue> = {}): number
  loop(cue: Cue | string, extra: Partial<Cue> = {}): number
  stop(handleOrTag: number | string): void
  stopAll(): void
  handleOf(tag: string): number | null
  get playing(): number[]
  bus(name: AudioBus, volume: number, seconds = 0): boolean
  snapshot(name: string): boolean
  music(layer: string, crossfade = 0): number
  fire(cue: AudioCue | string): number
  on(event: string, cue: AudioCue | string): this
  off(event: string): this
  handle(ev: GameEvent): number[]
  applyComponent(component: AudioComponent, at?: Target, tag = "component"): number | null
  applyEntityComponent(tag = "component"): number | null
}

Import: import { AudioDirector } from "@argus/gameplay"

Members

MemberSignatureDescription
defaultBusdefaultBus: AudioBus
masterVolumemasterVolume: number
constructorconstructor(ctx: Ctx, opts: AudioDirectorOptions = {})
playplay(cue: Cue | string, extra: Partial<Cue> = {}): numberStart a cue. Returns the engine handle. A tagged cue replaces whatever that tag was playing.
looploop(cue: Cue | string, extra: Partial<Cue> = {}): numberStart a cue looping.
stopstop(handleOrTag: number | string): voidStop a handle or a tag. Unknown tags and already-stopped handles are ignored.
stopAllstopAll(): voidStop everything this director started.
handleOfhandleOf(tag: string): number | nullThe handle a tag is playing on, or null.
playingget playing(): number[]Handles started by this director and not yet stopped.
busbus(name: AudioBus, volume: number, seconds = 0): booleanRamp a bus of the scene's mixer graph. False when the scene declares no such bus. The director does not keep bus state: the mixer owns it, one graph for the whole scene, and two behaviors both ducking music would otherwise each believe they had set it back.
snapshotsnapshot(name: string): booleanCross-fade to a named snapshot. False when the scene declares no such snapshot.
musicmusic(layer: string, crossfade = 0): numberChange music layer at the next bar line. Returns the handle of whatever is sounding now, which is 0 before the first layer starts.
firefire(cue: AudioCue | string): numberRun one cue now, whichever kind it is. Returns a handle for the two that make one.
onon(event: string, cue: AudioCue | string): thisBind a cue to an event name. Several cues may share an event, and they run in order.
offoff(event: string): thisUnbind every cue for an event.
handlehandle(ev: GameEvent): number[]Fire the cues bound to a delivered event. Returns the handles started; a bus or snapshot cue contributes nothing to play, so it contributes no handle either.
applyComponentapplyComponent(component: AudioComponent, at?: Target, tag = "component"): number | nullApply an audio component: spatial cues follow at (the owning entity by default), and the component plays now when it autoplays. Returns the handle, or null when it is waiting to be triggered.
applyEntityComponentapplyEntityComponent(tag = "component"): number | nullApply the audio component on the behavior's own entity, if it has one.