Prowl’s audio system is built on top of OpenAL, giving you hardware-accelerated spatial sound out of the box. The engine exposes a clean, component-driven API throughDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl/llms.txt
Use this file to discover all available pages before exploring further.
AudioSource and AudioListener, while the static AudioSystem class lets you fire one-shot sounds and background music without attaching anything to a GameObject. Whether you need a looping ambient track, a 3D footstep effect that fades with distance, or a UI click that ignores the listener position entirely, Prowl handles it through a unified pool of ActiveAudio handles that you can adjust in real-time.
Audio System Initialization
AudioSystem.Initialize() is called automatically by the engine at startup. It attempts to create an OpenALEngine; if that fails (for example on a headless server), it silently falls back to NullAudioEngine so the rest of your code continues to run without modification.
Only one
AudioListener may be active at a time. If a second listener is registered, Prowl logs a warning and ignores it. Destroy the first listener before creating a new one when switching cameras.Components
AudioListener
AudioListener tells the engine where the “ears” are in your scene. Attach it to your main camera or player GameObject. Every frame it forwards the transform’s position, velocity, and orientation to the OpenAL backend so that 3D sounds are spatialized correctly.
AudioSystem on OnEnable and unregisters on OnDisable, so enabling/disabling the camera naturally updates which listener is active.
AudioSource
AudioSource is the workhorse component for scene-attached sounds. It manages its own ActiveAudio source internally and updates the position every frame relative to the registered listener.
| Property | Type | Default | Description |
|---|---|---|---|
Clip | AssetRef<AudioClip> | — | The audio clip to play |
PlayOnAwake | bool | true | Play automatically when the component starts |
Looping | bool | false | Loop the clip continuously |
Volume | float | 1.0 | Gain multiplier (0–1) |
MaxDistance | float | 32.0 | Distance at which the sound is completely silent |
_source.Stop() at any time to halt playback. When the component is disabled it stops automatically; when it is destroyed the underlying OpenAL source is disposed.
AudioClip Asset
AudioClip is a serialized runtime asset that stores raw PCM audio data together with metadata (sample rate, bit depth, channel count). Load it through the asset reference system:
AudioClipImporter handles .wav, .wave, and .ogg files. Once imported, the clip is cached in AudioSystem as an AudioBuffer so repeated calls to PlaySound do not re-upload data to the audio hardware.
AudioSystem API
For sounds that do not need a persistent scene object — explosions, UI clicks, one-shot voice lines — callAudioSystem.PlaySound directly. All overloads return an ActiveAudio handle.
PlaySound Overloads
| Signature | Description |
|---|---|
PlaySound(AudioClip clip) | Full volume, listener-relative. |
PlaySound(AudioClip clip, float volume) | Custom volume, listener-relative. |
PlaySound(AudioClip clip, float volume, float pitch) | Custom volume and pitch, listener-relative. |
PlaySound(AudioClip clip, float volume, float pitch, Vector3 position, AudioPositionKind positionKind) | Custom volume, pitch, and 3D position. |
ActiveAudio Handle
PlaySound returns an ActiveAudio object that lets you modify or stop the sound while it is still playing.
ActiveAudio handles are managed by the engine’s internal source pool. Stopped or finished sources are automatically returned to the pool by AudioSystem.UpdatePool(), which the engine calls each frame. Do not call Dispose() on handles returned from PlaySound — only call it on sources you created directly via AudioSystem.Engine.CreateAudioSource().
Code Examples
- Background Music
- 3D Footstep
- One-Shot Effect
AudioBuffer and AudioBufferPool
AudioBuffer is the low-level representation of decoded PCM data uploaded to the audio backend. AudioSystem.GetAudioBuffer(clip) lazily uploads the clip and caches the result in a dictionary keyed by AudioClip instance. You typically never need to create or destroy buffers manually — they live for the lifetime of the engine session and are disposed in AudioSystem.Dispose().