Package-level declarations
Overview
Audio playback system providing sound effects and music management for the application. Supports loading, modifying, and playing audio files with various controls.
Key Components
AudioWrapper— Wrapper around Java Sound API for playing audio filesLoads audio from URLs
Supports volume, pitch, and playback speed control
Provides play, pause, stop, and loop functionality
AudioModifier— Fluent API for configuring audio propertiesSet loop count (including infinite looping)
Configure volume levels
Adjust playback speed and pitch
AudioPool— Collection manager for multiple audio tracksStores and retrieves audio by name
Provides builder pattern for pool construction
Supports batch loading of audio resources
BooleanControlWrapper— Wrapper for on/off audio controls (mute, etc.)FloatControlWrapper— Wrapper for continuous audio controls (volume, pan, etc.)
Responsibilities
Loading audio files from resources or URLs
Playing sound effects and background music
Managing audio playback state (play, pause, stop)
Controlling audio properties (volume, pitch, speed, looping)
Providing a simple API for game audio management
Handling audio control types (boolean and float controls)
Usage Examples
// Load a single audio file
val audio = loadAudio("click", url)
// Load audio with infinite looping
val music = loadAudio("theme", url, AudioModifier().setToLoopInfinitely())
// Build an audio pool
val audioPool = buildAudioPool {
add(loadAudio("click", clickUrl))
add(loadAudio("move", moveUrl))
add(loadAudio("capture", captureUrl))
}
// Play audio from pool
audioPool["click"]?.play()Notes
Uses Java Sound API (
javax.sound.sampled) for audio playbackSupports common audio formats (WAV, AIFF, AU)
Audio controls depend on the underlying audio format and system capabilities
Gracefully handles missing controls with fallback behavior
Types
Represents a pool of audio tracks that can be managed together.
A wrapper for an audio Clip, providing methods to control playback and audio properties.