|
Kemena3D
|
Owns the miniaudio engine and acts as a factory for kAudio instances. More...
#include <kaudiomanager.h>
Public Member Functions | |
| kAudioManager () | |
| Constructs the manager; call init() before use. | |
| ~kAudioManager () | |
| Destroys the manager, calling shutdown() if still active. | |
| bool | init () |
| Initialises the underlying miniaudio engine. | |
| void | shutdown () |
| Stops all sounds, unloads every kAudio, and tears down the engine. Called automatically by the destructor. | |
| void | setMasterVolume (float volume) |
| Sets the master output volume. | |
| float | getMasterVolume () const |
| Returns the current master volume. | |
| void | setListenerPosition (const kVec3 &position) |
| Moves the audio listener to a new world-space position. | |
| void | setListenerDirection (const kVec3 &forward, const kVec3 &up) |
| Sets the listener's orientation. | |
| void | setListenerVelocity (const kVec3 &velocity) |
| Sets the listener's velocity for Doppler shift calculation. | |
| kAudio * | loadAudio (const kString &filePath) |
| Loads an audio file and returns a new kAudio instance. | |
| void | unloadAudio (kAudio *audio) |
| Stops and destroys a previously loaded kAudio. | |
Owns the miniaudio engine and acts as a factory for kAudio instances.
Create one kAudioManager per application. Call init() before loading any audio, and shutdown() (or let the destructor do it) when done.
| kemena::kAudioManager::kAudioManager | ( | ) |
Constructs the manager; call init() before use.
| kemena::kAudioManager::~kAudioManager | ( | ) |
Destroys the manager, calling shutdown() if still active.
| float kemena::kAudioManager::getMasterVolume | ( | ) | const |
Returns the current master volume.
| bool kemena::kAudioManager::init | ( | ) |
Initialises the underlying miniaudio engine.
Loads an audio file and returns a new kAudio instance.
The returned pointer is owned by this manager. Release it with unloadAudio() rather than deleting it directly.
Supports any format miniaudio accepts: WAV, MP3, FLAC, OGG (via stb_vorbis).
| filePath | Path to the audio file. |
Sets the listener's orientation.
| forward | Normalised forward vector. |
| up | Normalised up vector. |
| void kemena::kAudioManager::setListenerPosition | ( | const kVec3 & | position | ) |
Moves the audio listener to a new world-space position.
| position | Listener position (typically the camera position). |
| void kemena::kAudioManager::setListenerVelocity | ( | const kVec3 & | velocity | ) |
Sets the listener's velocity for Doppler shift calculation.
| velocity | Velocity in world units per second. |
| void kemena::kAudioManager::setMasterVolume | ( | float | volume | ) |
Sets the master output volume.
| volume | Linear scalar; 0.0 = mute, 1.0 = full volume. |
| void kemena::kAudioManager::shutdown | ( | ) |
Stops all sounds, unloads every kAudio, and tears down the engine. Called automatically by the destructor.
| void kemena::kAudioManager::unloadAudio | ( | kAudio * | audio | ) |
Stops and destroys a previously loaded kAudio.
| audio | Pointer returned by loadAudio(). |