AudioBusHandle
Since 0.6
One bus of the mixer graph, by name.
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
| Member | Signature | Description |
|---|---|---|
name | readonly name: string | The name this handle was created with, declared or not. |
setVolume | setVolume(volume: number, seconds?: number): boolean | 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. |
Example
The tested fixture crates/editor/templates/behaviours/empty.ts.
import type { Behavior } from "@argus/api"
/**
* A behaviour with nothing in it yet.
*
* `update` runs every fixed tick with `dt` at 1/60 s; `init` runs once after attach and again
* after each hot reload, with `ctx.state` preserved. Everything a behaviour can reach hangs off
* `ctx`: `ctx.entity` is the entity this is attached to, `ctx.world` queries the scene,
* `ctx.events` is the bus every other behaviour listens on, and `ctx.props` is a read-only copy
* of the `props` the Details panel shows.
*
* Add a property in the Details panel and read it here as `ctx.props.<name>`.
*/
interface State {
/** Whatever this behaviour needs to remember between ticks. Must stay JSON-serialisable. */
ticks: number
}
interface Props {
/** Every key the Details panel's Add property row introduces arrives here. */
[key: string]: unknown
}
export default {
init(ctx) {
if (typeof ctx.state.ticks !== "number") ctx.state.ticks = 0
},
update(ctx) {
ctx.state.ticks += 1
},
} satisfies Behavior<State, Props>