AppMixer beta
Class of @v12-engine/client
export declare class AppMixerThe sound of a whole app: see the top of this file. Made once for an app (ClientRuntime.mixer), or by a SoundPlayer given none, for itself alone
const mixer = await app.runtime.mixer() mixer.bus('radio', label: 'Radio', level: 0.6, speaks: true ) mixer.snapshot('inside', buses: ambience: 0.3 , lowpass: 900 ) mixer.recall('inside', 0.5)
Members
constructor
constructor(options?: MixerOptions & {
storage?: KeptStorage;
});Constructs a new instance of the AppMixer class
bus
bus(id: Bus, options?: BusOptions): MixerBus;A bus: one of the client's, or a game's own, made as it is first named (BusOptions). Its volume is the player's like any other, kept for the next game, and in the HUD's mixer
configure
configure(options?: MixerOptions): void;What is declared of the mix (MixerOptions), over what was: what it does not say stays
context
get context(): AudioContext;The context, made as the first sound needs it: a browser complains of one made before a click
crossfade
crossfade: number;Seconds music takes to go over to other music, where nothing says (MixerOptions.crossfade)
dispose
dispose(): void;Stops the music and any fades, removes the unlock listeners and closes the audio context
duck
duck(options: DuckOptions): void;How far and how fast the buses that duck go down while someone speaks
hold
hold(held: boolean): void;Holds every sound, music too, where it is, or lets them go on: an editor's own while a game is played over it, whose keys and clicks would otherwise wake them
isMuted
get isMuted(): boolean;Whether the player has muted all sound
label
label(id: Bus): string | undefined;What a bus is called in the mixer: the words a game's own says, none for the client's five
leave
leave(who: object, scaled: Iterable<Bus>): void;What a scene set on the mix goes as it goes: its pause, its cinematic's scales, the snapshot it went to, its music
letGoMusic
letGoMusic(owner: object, seconds?: number): void;Music comes to an end with who it belongs to, faded over seconds, unless someone took it over: what a game's music does as nothing after it says otherwise. A menu's stays until a scene says
level
level(bus: Bus | 'master'): number;The volume of a bus, or of everything, 0..1
levels
levels(): SoundLevels;The volumes the player set, of everything and of each bus
listen
listen(told: () => void): () => void;Told each time the player's mix is set or a bus is added. Gives back what stops it
musicTracks
get musicTracks(): string[];The music playing now: its tracks, none for none
musicVolume
musicVolume(level: number, seconds?: number): void;The music's own volume (0 to 1), eased over seconds
node
node(id: Bus): GainNode;The Web Audio node of a bus, which what is heard on it goes into
onPause
onPause(options: MixerPause): void;What a pause does to the sound (MixerPause)
pause
pause(on: boolean, who?: object): void;The game paused or going on, for who (the sound is paused while anyone holds it): what onPause says then. The client says it itself, of its pause menu and a server's pause
paused
get paused(): boolean;Whether anyone holds the sound paused
playFile
playFile(url: string, options?: {
bus?: Bus;
volume?: number;
}): MixerFile;A file heard through the mix, once, on a bus (a voice by default: the buses that duck go down while it lasts): what a screen of the app plays that is not a sound of a game's folder (a mission's briefing)
playingMusic
playingMusic(): CutMusic | undefined;The music playing now, as code reaches it (CutMusic): its element, its volume's node. None for none
recall
recall(name?: string, seconds?: number, who?: object): void;Goes to a state of the mix by its name over seconds, or back to the mix as the player set it with no name. who: as they go, the mix goes back with them (a game ended on the inside of a cave leaves no cave over the menu). A name there is none of says so
resume
resume(): void;Wakes the sound, as a click or a key has: what is started while the context wakes up plays once it has
scale
scale(bus: Bus, level: number, seconds?: number): void;A bus at level of the player's volume for it (1 as they set it), eased over seconds: a cinematic's say over the mix (D1)
setLevel
setLevel(bus: Bus | 'master', level: number): void;Sets the volume of a bus, or of everything. Remembered for the next game
setMusic
setMusic(tracks: readonly string[], options?: MusicOptions): void;Plays other music, or none: the tracks one after the other, over and over. Music already playing the same files goes on as it is, under its new owner: what carries from a menu into a mission
setMuted
setMuted(muted: boolean): void;Turns all sound off or on again. Remembered for the next game
snapshot
snapshot(name: string, state?: MixerSnapshot): MixerSnapshot;A state of the mix to go to by name (recall): as state says, or as the mix stands now, the player's own volumes apart. Gives back what it keeps
speak
speak(started: boolean): void;Someone started saying a line, or finished one: the buses that duck go down, or back
speaks
speaks(id: Bus): boolean;Whether what plays on this bus is someone speaking: the buses that duck go down for it
unlocked
unlocked: boolean;Whether the player has clicked or pressed a key yet. Until then nothing may play