Audio · class

MixConsole

Explained in Your first game.

class MixConsole
import { MixConsole } from '@driftengine/audio';

Constructor

new

constructor(context: BaseAudioContext, options?: MixConsoleOptions)
ParameterTypeDescription
contextBaseAudioContext
options?MixConsoleOptions

Properties

NameTypeDescription
contextreadonlyBaseAudioContext
masterreadonlyMixBusEverything ends up here. Its insert chain is where a master filter belongs.
outreadonlyGainNodeWhat reaches the speakers, summed in one place.
More

The same node, for the same reason, as the out that AudioGraph grew after every exported clip turned out to be missing its send returns: "what the player hears" has to be a node, or the moment anything wants to listen to the mix there is nowhere to listen.

Accessors

NameTypeDescription
allgetreadonly MixBus[]

Methods

bus

bus(name: string, options?: BusOptions): MixBus

The bus called name, created under master if it does not exist yet.

ParameterTypeDescription
namestring
options?BusOptions
More

One verb rather than a create and a get, because a caller declaring a bus at startup and a caller reaching for one by name are asking the same question, and two verbs would mean choosing between them on every line. Cost: a typo makes a bus instead of an error. What would make this wrong is a console large enough to lose one in, which is when a caller should be holding the reference rather than the name.

find

find(name: string): MixBus | undefined
ParameterTypeDescription
namestring

at

at(seconds: number | null): void

Schedule everything that follows at seconds on this context's timeline, or at "now" when null.

ParameterTypeDescription
secondsnumber | null
More

An offline render sets it once per frame and gets a mix whose every move lands exactly where the picture is. Live callers never touch it.

Has no effect when a scheduleAt was supplied, because then somebody else owns the answer and this console is a reader of it. That is the case whenever an AudioGraph built the console: the transport's own at() is the one to call.

scheduleAt

scheduleAt(): number

The instant scheduled work lands on. One reader, so "when" has one answer in a mix.

random

random(): number

See MixConsoleOptions.random.

snapshot

snapshot(name: string): MixSnapshot

Capture every level, mute and send, under a name.

ParameterTypeDescription
namestring

recall

recall(name: string, seconds?: number): boolean

Crossfade back to a captured snapshot over seconds. False, and nothing moves, when no snapshot was taken under that name.

ParameterTypeDescription
namestring
seconds?number