mwg API
    Preparing search index...

    Class Sound

    A sound effect, pooled so the same clip can overlap itself. A dozen arrows landing in the same second must not cut each other off, which a single <audio> element would - the next play just steals the oldest of the pool, round-robin, rather than restarting the one already mid-sound.

    import { Sound } from '@datamoc/mw_games/audio';

    const hit = new Sound('sounds/hit.mp3', { poolSize: 6, caption: 'a sword strikes' });
    hit.play(); // safe to call several times in the same second
    Index
    volume: number
    • Plays one instance from the pool.

      Parameters

      • gain: number = 1

        multiplied into the sound's own volume, for a distance-attenuated one-shot (Positional.SoundSource.playFor); 1 leaves it at volume.

      Returns void