Phaser Sound Studio - Main

Advanced audio management system for Phaser 3 games with sound effects and music control.

Sound Studio Main

Advanced audio management system for Phaser 3 games with sound effects and music control. This example demonstrates how to play sounds using the Phaser Sound Studio.

Features

  • đŸŽĩ Sound Management: Centralized sound loading and playback
  • đŸŽšī¸ Channel System: Organize sounds by channels (HUD, SFX, Music, etc.)
  • ⚡ Performance: Optimized audio loading and caching
  • 🔧 Type Safety: Full TypeScript support with sound key validation

Live Example

Loading game...

Usage Example

import { getSoundStudio, PHASER_SOUND_STUDIO_KEY, PhaserSoundStudioPlugin, SoundListConfig } from 'phaser-sound-studio';

// Define sound keys and channels
const SOUND_KEYS = {
    MOUSE_HOVER: 'mouse-hover',
    MOUSE_CLICK: 'mouse-click',
} as const;

const SOUND_CHANNELS = {
    HUD: 'hud',
    BACKGROUND: 'background',
    SFX: 'sfx',
    MUSIC: 'music',
    VOICE: 'voice'
} as const;

// Configure sounds
const soundKeys: SoundListConfig<SoundKeys, ChannelKeys> = {
    [SOUND_KEYS.MOUSE_HOVER]: {
        channel: SOUND_CHANNELS.HUD,
        preload: true,
        path: '/sounds/ui-pop.m4a',
        loop: false,
    },
    [SOUND_KEYS.MOUSE_CLICK]: {
        channel: SOUND_CHANNELS.HUD,
        preload: true,
        path: '/sounds/click.mp3',
        loop: false,
    }
};

class GameScene extends Phaser.Scene {
    preload(): void {
        // Load all sounds
        getSoundStudio(this).loadAll(this);
    }

    create(): void {
        // Play sounds
        getSoundStudio<SoundKeys, ChannelKeys>(this).play(this, SOUND_KEYS.MOUSE_CLICK);
    }
}

Configuration

Sound Configuration

  • â€ĸ channel - Audio channel for organization
  • â€ĸ preload - Whether to preload the sound
  • â€ĸ path - Path to the sound file
  • â€ĸ loop - Whether the sound should loop

Channels

  • â€ĸ HUD - UI sound effects
  • â€ĸ SFX - Game sound effects
  • â€ĸ MUSIC - Background music
  • â€ĸ VOICE - Voice/dialogue audio