Skip to main content
Prisma Engine’s audio system provides cross-platform sound playback through a two-layer Driver-Device abstraction. The 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.
Enable the SDL3 backend at configure time:

Native backends

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.
Do not attempt to enable PRISMA_ENABLE_AUDIO_XAUDIO2 in production builds. The XAudio2 device implementation is out of sync with the current IAudioDevice interface and will fail to link.

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 implement IAudioDevice. 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 after Play.
Distance attenuation models available via DistanceModel:

Usage example

CMake configuration

Set PRISMA_USE_NATIVE_AUDIO=OFF to force SDL3 on all platforms: