IAudioDevice interface decouples game logic from platform APIs, while pluggable backends handle the actual hardware interaction. SDL3 is the primary cross-platform backend; XAudio2 (Windows) and AAudio (Android) are planned native alternatives.
Driver-Device pattern
The audio stack separates concerns across two layers:AudioDevice (the concrete manager) selects a backend at runtime based on the AudioDesc::deviceType field. Set AudioDeviceType::Auto to let the engine pick the best available backend for the current platform.
SDL3 backend
AudioDeviceSDL3 is the default cross-platform backend. It opens an SDL_AudioDeviceID, mixes voices via SDL_AudioStream, and supports up to 256 concurrent voices by default.
Native backends
- XAudio2 (Windows)
- AAudio (Android)
- Null device
XAudio2 is implemented in
src/engine/audio/AudioDeviceXAudio2.* and src/engine/audio/drivers/AudioDriverXAudio2.*, but it is currently disabled in CMakeLists.txt pending an interface refactor. The PRISMA_ENABLE_AUDIO_XAUDIO2 option exists but has no effect until the refactor is complete.Core types
AudioClip
AudioClip is the engine’s unified PCM container. Load audio files through AssetManager or decode them manually before constructing a clip.
PlayDesc
PlayDesc controls per-voice playback settings including 3D spatial attributes:
IAudioDevice interface
All backends implementIAudioDevice. The key methods are:
3D spatial audio
The audio system models sound in 3D space using a listener-source model. Update the listener position every frame from your camera transform, then set per-voice 3D attributes before or afterPlay.
DistanceModel:
Usage example
CMake configuration
Set
PRISMA_USE_NATIVE_AUDIO=OFF to force SDL3 on all platforms: