Exception raised for audio-related errors.
No methods defined.
Audio playback states.
STOPPED: Any = 'stopped'
PLAYING: Any = 'playing'
PAUSED: Any = 'paused'
FADING_IN: Any = 'fading_in'
FADING_OUT: Any = 'fading_out'
No methods defined.
Audio events.
PLAYBACK_STARTED: Any = 'playback_started'
PLAYBACK_STOPPED: Any = 'playback_stopped'
PLAYBACK_PAUSED: Any = 'playback_paused'
PLAYBACK_RESUMED: Any = 'playback_resumed'
PLAYBACK_COMPLETED: Any = 'playback_completed'
FADE_COMPLETE: Any = 'fade_complete'
LOOP: Any = 'loop'
No methods defined.
Information about a loaded sound.
Attributes:
name (str): Name of the sound
filepath (str): Path to the audio file
duration (float): Duration in seconds
channels (int): Number of audio channels
sample_rate (int): Sample rate in Hz
loaded_time (float): When the sound was loaded
def __init__(self: Any, name: str, filepath: str, duration: float = 0.0, channels: int = 2, sample_rate: int = 44100) -> Any
def __repr__(self: Any) -> str
Audio channel for playback control.
Each channel can play one sound at a time with individual volume,
pitch, and pan controls.
Args:
channel_id (int): Unique identifier for this channel
audio_system: Reference to the parent audio system
def __init__(self: Any, channel_id: int, audio_system: 'AudioSystem') -> Any
def play(self: Any, sound_name: str, loop: bool = False) -> bool
def set_volume(self: Any, volume: float, duration: float = 0.0) -> Any
def _start_volume_transition(self: Any, target_volume: float, duration: float) -> Any
def _transition_volume(self: Any, start: float, end: float, duration: float) -> Any
def set_pitch(self: Any, pitch: float, duration: float = 0.0) -> Any
def set_pan(self: Any, pan: float) -> Any
def _update_pygame_volume(self: Any) -> Any
def pause(self: Any) -> Any
def resume(self: Any) -> Any
def stop(self: Any) -> Any
def is_playing(self: Any) -> bool
def is_paused(self: Any) -> bool
def get_playback_position(self: Any) -> float
def cleanup(self: Any) -> Any
Main audio system with sound management and channel allocation.
Features:
- Load sounds by name and store for reuse
- Automatic channel allocation or explicit channel selection
- Resource management and cleanup
- OpenAL backend with Pygame fallback
Args:
num_channels (int): Maximum number of concurrent audio channels
use_openal (bool): Whether to use OpenAL backend
def __init__(self: Any, num_channels: int = 16, use_openal: bool = None) -> Any
def _init_openal(self: Any) -> Any
def _init_pygame(self: Any) -> Any
def load_sound(self: Any, name: str, filepath: str) -> bool
def _estimate_duration(self: Any, filepath: str) -> float
def get_sound_info(self: Any, name: str) -> Optional[SoundInfo]
def get_sound_pygame(self: Any, name: str) -> Optional[pygame.mixer.Sound]
def play(self: Any, sound_name: str, channel: Optional[int] = None, volume: float = None, pitch: float = 1.0, pan: float = 0.0, loop: bool = False) -> Optional[AudioChannel]
def play_music(self: Any, sound_name: str, volume: float = None, pitch: float = 1.0, loop: bool = True, fade_in: float = 0.0) -> Optional[AudioChannel]
def stop_all(self: Any) -> Any
def pause_all(self: Any) -> Any
def resume_all(self: Any) -> Any
def set_master_volume(self: Any, volume: float) -> Any
def set_music_volume(self: Any, volume: float) -> Any
def set_sfx_volume(self: Any, volume: float) -> Any
def get_channel_info(self: Any) -> List[Dict]
def unload_sound(self: Any, name: str, force: bool = False) -> bool
def unload_unused_sounds(self: Any, max_age: float = 300.0) -> Any
def update(self: Any) -> Any
def cleanup(self: Any) -> Any