mwg API
    Preparing search index...

    Class Channel

    One buffered voice: a decoded track with a loop region and a playhead the game can read and move. Replaying the same buffer restarts it; changing parameters mid-play never does.

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

    declare const context: AudioContext;
    declare const buffer: AudioBuffer;

    const channel = new Channel(context);
    channel.play(buffer, { volume: 0.8, pitch: 1, pan: 0, loop: { start: 1, end: 4 } });
    console.log(channel.position());
    channel.stop();
    Index
    • seconds into the buffer, wrapping inside the loop region while it repeats

      Returns number

    • moves the playhead, restarting the voice when it plays

      Parameters

      • pos: number

      Returns void

    • stops the voice, fading out over fadeSeconds first when positive

      Parameters

      • fadeSeconds: number = 0

      Returns void

    • retunes the playing voice in place: no restart, no seek

      Parameters

      • params: { pan?: number; pitch?: number; volume?: number }

      Returns void