mwg API
    Preparing search index...

    Class StreamPlayable

    A BlockSource behind the Playable surface, so Music and Orchestrator can play a synthesised stream without knowing it is one. The behaviours HTMLAudioElement leaves implicit, decided here once:

    • currentTime reads the playhead and moves it by seeking the source; while a source loops it stays inside the loop region, and once a source that does not loop has ended it holds the duration. An endless source reports Infinity for duration.
    • playbackRate is supported by resampling: speed and pitch change together, from the next queued chunk (up to the lookahead later).
    • onended fires once when a source that does not loop plays out or an endless source reaches endAfterSeconds; a looping source never fires it.
    • the source's own sample rate is converted to the context's, so the caller never creates a context at a particular rate.
    • play() resumes a suspended context first, which a browser only allows after a gesture.
    import { StreamPlayable, type BlockSource } from '@datamoc/mwg/audio';

    declare const context: AudioContext;
    declare const tune: BlockSource;

    const stream = new StreamPlayable(context, tune);
    stream.loop = true;
    stream.volume = 0.7;
    void stream.play();

    Implements

    Index
    channel: StreamChannel

    the underlying voice, for underrun reports and the other things Playable has no word for

    onended: ((event: Event) => unknown) | null = null

    Optional completion hook, matching HTMLAudioElement.onended. Backends without an end event can omit it; single-track Music remains fully usable there.