Talos docs

AudioBusHandle

Since 0.6

One bus of the mixer graph, by name.

Plain text

Signature

export interface AudioBusHandle {
  /** The name this handle was created with, declared or not. */
  readonly name: string
  /**
   * Ramp this bus to `volume` over `seconds`; omitting the time is a step. Returns false
   * when the scene declares no bus by this name — which the critic reports as
   * `audio-bus-unknown` long before the scene runs.
   */
  setVolume(volume: number, seconds?: number): boolean
}

Import: import type { AudioBusHandle } from "@argus/api"

Members

MemberSignatureDescription
namereadonly name: stringThe name this handle was created with, declared or not.
setVolumesetVolume(volume: number, seconds?: number): booleanRamp this bus to volume over seconds; omitting the time is a step. Returns false when the scene declares no bus by this name — which the critic reports as audio-bus-unknown long before the scene runs.

Example

The tested fixture fixtures/recipes/many-entities/scenes/behaviors/beacon.ts.

import type { Behavior } from "@argus/api"

/** A beacon: counts the drones that touch it. Only this beacon hears its touches (`emitTo`). */
interface State {
  touches: number
}

export default {
  init(ctx) {
    ctx.state.touches ??= 0
  },
  onEvent(ctx, ev) {
    if (ev.name === "touched") ctx.state.touches += 1
  },
} satisfies Behavior<State>