mwg API
    Preparing search index...

    Class AudioBus

    The four audio lifetimes of a role-playing game over two Channel voices: BGM and BGS loop independently, an ME jingle suspends the BGM and resumes it where it left off, SE plays overlapping one-shots. Replaying the current track only retunes it; save and replay memorize a track with its playhead for menus and transfers.

    import { AudioBus } from '@datamoc/mwg/audio';

    declare const context: AudioContext;

    const bus = new AudioBus(context, { load: (_kind, _name) => Promise.resolve(null) });
    void bus.playBgm({ name: 'town', volume: 90, pitch: 100, pan: 0 });
    console.log(bus.snapshot());
    Index
    onLoadProgress: Signal<BusLoadProgress> = ...

    told as a loader reports progress, for a loading bar over a long render

    • Plays a jingle once, suspending the BGM and resuming it where it left off when the jingle ends. A BGM started mid-jingle takes over instead of being resumed over.

      Parameters

      Returns Promise<void>

    • Sets a kind's own volume (0 to 1) and mute, applied on top of every track's volume and to sounds already playing. Tracks keep the level the game asked for, so snapshot() never reports the mixer's scaling.

      Parameters

      • kind: BusKind
      • level: { muted?: boolean; volume?: number }

      Returns void

    • stops the jingle, resuming the suspended BGM unless told not to

      Parameters

      • resume: boolean = true

      Returns void