Low-level audio system that interfaces directly with miniaudio.
More...
#include <audio_system.h>
Low-level audio system that interfaces directly with miniaudio.
The AudioSystem class handles the core audio functionality, including initialization of the miniaudio engine and creation of sounds and groups. It manages the underlying audio resources and provides a layer of abstraction over the miniaudio library.
AudioSystem is not meant to be used directly by game code; instead, it's accessed through the AudioManager.
◆ AudioSystem()
| audio::AudioSystem::AudioSystem |
( |
| ) |
|
Constructor.
Initializes the miniaudio engine
◆ ~AudioSystem()
| audio::AudioSystem::~AudioSystem |
( |
| ) |
|
Destructor.
Cleans up all audio resources and uninitializes the miniaudio engine
◆ CreateGroup()
| std::unique_ptr< AudioGroup > audio::AudioSystem::CreateGroup |
( |
| ) |
|
Creates a new AudioGroup object.
Creates an audio group for collective control of sounds. The caller takes ownership of the returned unique_ptr.
- Returns
- std::unique_ptr<AudioGroup> Unique pointer to the newly created AudioGroup (caller owns)
◆ CreateSound()
| std::unique_ptr< Sound > audio::AudioSystem::CreateSound |
( |
const std::string & |
filepath, |
|
|
AudioGroup * |
group = nullptr |
|
) |
| |
Creates a new Sound object.
Loads an audio file and creates a Sound object. The caller takes ownership of the returned unique_ptr.
- Parameters
-
| filepath | Path to the audio file |
| group | Optional pointer to the group to add the sound to |
- Returns
- std::unique_ptr<Sound> Unique pointer to the newly created Sound (caller owns)
◆ GetEngine()
| ma_engine * audio::AudioSystem::GetEngine |
( |
| ) |
|
|
inline |
Get access to the miniaudio engine (for advanced use)
- Returns
- ma_engine* Pointer to the miniaudio engine
◆ GetListenerDirection()
| Vec3 audio::AudioSystem::GetListenerDirection |
( |
ma_uint32 |
listenerIndex = 0 | ) |
const |
Get the listener direction.
- Parameters
-
| listenerIndex | Index of the listener (default 0) |
- Returns
- Vec3 Current listener direction
◆ GetListenerPosition()
| Vec3 audio::AudioSystem::GetListenerPosition |
( |
ma_uint32 |
listenerIndex = 0 | ) |
const |
Get the listener position.
- Parameters
-
| listenerIndex | Index of the listener (default 0) |
- Returns
- Vec3 Current listener position
◆ GetListenerUp()
| Vec3 audio::AudioSystem::GetListenerUp |
( |
ma_uint32 |
listenerIndex = 0 | ) |
const |
Get the listener up vector.
- Parameters
-
| listenerIndex | Index of the listener (default 0) |
- Returns
- Vec3 Current listener up vector
◆ GetMasterVolume()
| float audio::AudioSystem::GetMasterVolume |
( |
| ) |
const |
|
inline |
Gets the current master volume.
- Returns
- float Current master volume (0.0 to 1.0)
◆ SetListenerDirection()
| void audio::AudioSystem::SetListenerDirection |
( |
const Vec3 & |
direction, |
|
|
ma_uint32 |
listenerIndex = 0 |
|
) |
| |
Set the listener direction (forward vector)
The direction vector represents which way the listener is facing. Should be normalized.
- Parameters
-
| direction | Forward direction vector (should be normalized) |
| listenerIndex | Index of the listener (default 0) |
◆ SetListenerPosition()
| void audio::AudioSystem::SetListenerPosition |
( |
const Vec3 & |
position, |
|
|
ma_uint32 |
listenerIndex = 0 |
|
) |
| |
Set the listener position in 3D space.
The listener represents the "ears" of the player/camera. All spatialized sounds are positioned relative to the listener.
- Parameters
-
| position | 3D position of the listener |
| listenerIndex | Index of the listener (default 0) |
◆ SetListenerUp()
| void audio::AudioSystem::SetListenerUp |
( |
const Vec3 & |
up, |
|
|
ma_uint32 |
listenerIndex = 0 |
|
) |
| |
Set the listener up vector.
The up vector defines the orientation of the listener. Typically (0, 1, 0) for a standard Y-up coordinate system.
- Parameters
-
| up | Up vector (should be normalized) |
| listenerIndex | Index of the listener (default 0) |
◆ SetMasterVolume()
| void audio::AudioSystem::SetMasterVolume |
( |
float |
volume | ) |
|
Sets the master volume for all audio.
- Parameters
-
| volume | Volume level (0.0 to 1.0) |
◆ cached_listener_direction_
| Vec3 audio::AudioSystem::cached_listener_direction_ |
|
mutableprivate |
Cached listener direction.
◆ cached_listener_position_
| Vec3 audio::AudioSystem::cached_listener_position_ |
|
mutableprivate |
Cached listener position to avoid redundant updates.
◆ cached_listener_up_
| Vec3 audio::AudioSystem::cached_listener_up_ |
|
mutableprivate |
Cached listener up vector.
◆ engine_
| ma_engine audio::AudioSystem::engine_ |
|
private |
miniaudio engine instance
◆ listener_state_dirty_
| bool audio::AudioSystem::listener_state_dirty_ |
|
mutableprivate |
Flag to track if listener state needs update.
◆ master_volume_
| float audio::AudioSystem::master_volume_ |
|
private |
The documentation for this class was generated from the following files: