mwg API
    Preparing search index...

    Class SfxArbiter

    The shared voice limit between chip effects and the bus's 'se' jingles: both ask here before they sound, and when the limit is reached the lowest-priority voice (the oldest among equals) is cut for a new one of equal or higher priority; a new one below everything sounding is refused. One arbiter handed to a bus and to every SfxSound makes them a single pool.

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

    const arbiter = new SfxArbiter({ maxVoices: 2 });
    const a = arbiter.request(1, () => console.log('a cut'));
    arbiter.request(1, () => console.log('b cut'));
    arbiter.request(5, () => console.log('c cut')); // cuts a, the oldest of the lowest priority
    a?.release();
    Index
    • Asks for a slot. stop cuts the voice when a better one needs its place; active says whether it still sounds, so a voice that ended by itself frees its slot for any asker, not only for the sound that owned it.

      Parameters

      • priority: number
      • stop: () => void
      • active: () => boolean = ...

      Returns SfxGrant | null