Strata - v1.4.10
    Preparing search index...

    Class SoundManager

    Manages 2D audio playback using Howler.js.

    const manager = createSoundManager({ masterVolume: 0.8 });

    await manager.load('explosion', { src: '/audio/explosion.mp3' });
    manager.play('explosion');

    manager.setBusVolume('sfx', 0.5);
    manager.dispose();
    Index

    Constructors

    Methods

    • Creates a new audio bus.

      Parameters

      • busId: string

        Unique bus identifier

      • volume: number = 1

        Initial volume (0.0 to 1.0)

      Returns void

      manager.createBus('ui', 0.8);
      
    • Fades the volume of a sound.

      Parameters

      • id: string

        Sound identifier

      • from: number

        Start volume (0.0 to 1.0)

      • to: number

        End volume (0.0 to 1.0)

      • duration: number

        Fade duration in milliseconds

      • OptionalsoundId: number

        Optional specific sound instance ID

      Returns void

      manager.fade('bgm', 0, 1, 2000);
      
    • Gets the volume of an audio bus.

      Parameters

      • busId: string

        Bus identifier

      Returns number | undefined

      Volume level or undefined if bus not found

    • Gets the volume of a sound.

      Parameters

      • id: string

        Sound identifier

      Returns number | undefined

      Volume level or undefined if not found

    • Checks if a sound is currently playing.

      Parameters

      • id: string

        Sound identifier

      Returns boolean

      True if playing

    • Loads a sound into the manager.

      Parameters

      • id: string

        Unique identifier for the sound

      • soundConfig: SoundConfig

        Sound configuration

      • bus: string = 'sfx'

        Audio bus to assign the sound to

      Returns Promise<void>

      Promise that resolves when loaded

      await manager.load('bgm', {
      src: ['/audio/music.mp3', '/audio/music.ogg'],
      loop: true,
      volume: 0.7,
      }, 'music');
    • Pauses a sound.

      Parameters

      • id: string

        Sound identifier

      • OptionalsoundId: number

        Optional specific sound instance ID

      Returns void

    • Plays a loaded sound.

      Parameters

      • id: string

        Sound identifier

      • Optionalsprite: string

        Optional sprite name to play

      Returns number | undefined

      The Howl sound ID or undefined if not found

      manager.play('explosion');
      manager.play('footsteps', 'step1');
    • Mutes or unmutes an audio bus.

      Parameters

      • busId: string

        Bus identifier

      • muted: boolean

        Whether to mute

      Returns void

    • Sets volume for an audio bus, affecting all sounds in the bus.

      Parameters

      • busId: string

        Bus identifier

      • volume: number

        Volume level (0.0 to 1.0)

      Returns void

      manager.setBusVolume('music', 0.3);
      
    • Sets the master volume for all audio.

      Parameters

      • volume: number

        Volume level (0.0 to 1.0)

      Returns void

    • Mutes or unmutes a sound.

      Parameters

      • id: string

        Sound identifier

      • muted: boolean

        Whether to mute

      Returns void

    • Sets volume for a specific sound.

      Parameters

      • id: string

        Sound identifier

      • volume: number

        Volume level (0.0 to 1.0)

      • OptionalsoundId: number

        Optional specific sound instance ID

      Returns void

      manager.setVolume('bgm', 0.5);
      
    • Stops a sound.

      Parameters

      • id: string

        Sound identifier

      • OptionalsoundId: number

        Optional specific sound instance ID

      Returns void

      manager.stop('bgm');