Singleton class that manages audio playback.
More...
#include <audiomanager.hpp>
|
| | AudioManager () |
| |
| | ~AudioManager () |
| |
| void | add (const Sound &sound) |
| | Adds a Sound object to the manager.
|
| |
| void | add (const std::string &path) |
| | Adds a sound from a file path, using the path as its name.
|
| |
| void | add (const std::string &path, const std::string &name) |
| | Adds a sound from a file path and assigns a name to it.
|
| |
| void | play (const std::string &name, bool loop=false) |
| | Plays a sound by name.
|
| |
| void | play (const Sound &sound, bool loop=false) |
| | Plays a Sound object directly.
|
| |
| void | stop (const std::string &name) |
| | Stops a sound by name.
|
| |
| void | stopAll () |
| | Stops all currently playing sounds.
|
| |
| void | pause (const std::string &name) |
| | Pauses a sound by name.
|
| |
| void | pauseAll () |
| | Pauses all currently playing sounds.
|
| |
| void | resume (const std::string &name) |
| | Resumes a paused sound by name.
|
| |
| void | resumeAll () |
| | Resumes all paused sounds.
|
| |
| void | setVolume (const std::string &name, float volume) |
| | Sets the volume of a sound by name.
|
| |
| void | setVolumeAll (float volume) |
| | Sets the volume of all sounds.
|
| |
| bool | isPlaying (const std::string &name) |
| | Checks whether a sound is currently playing.
|
| |
| bool | isPaused (const std::string &name) |
| | Checks whether a sound is currently paused.
|
| |
| float | getDuration (const std::string &name) |
| | Returns the total duration of a sound.
|
| |
| float | getPosition (const std::string &name) |
| | Returns the current playback position of a sound.
|
| |
| void | seek (const std::string &name, float seconds) |
| | Seeks to a specific position in a sound.
|
| |
|
| std::vector< Sound > | sounds |
| | Loaded sound objects.
|
| |
| std::vector< std::pair< ma_sound *, std::string > > | activeSounds |
| | Currently active sounds (handle, name)
|
| |
| ma_engine | engine {} |
| | miniaudio engine instance
|
| |
| bool | initialized = false |
| | Whether the engine has been initialized.
|
| |
Singleton class that manages audio playback.
Provides loading, playing, stopping, pausing and volume control of audio sources via the miniaudio engine.
◆ AudioManager()
| cangine::AudioManager::AudioManager |
( |
| ) |
|
◆ ~AudioManager()
| cangine::AudioManager::~AudioManager |
( |
| ) |
|
◆ add() [1/3]
| void cangine::AudioManager::add |
( |
const Sound & |
sound | ) |
|
Adds a Sound object to the manager.
- Parameters
-
◆ add() [2/3]
| void cangine::AudioManager::add |
( |
const std::string & |
path | ) |
|
Adds a sound from a file path, using the path as its name.
- Parameters
-
| path | Path to the audio file |
◆ add() [3/3]
| void cangine::AudioManager::add |
( |
const std::string & |
path, |
|
|
const std::string & |
name |
|
) |
| |
Adds a sound from a file path and assigns a name to it.
- Parameters
-
| path | Path to the audio file |
| name | Name to assign to the sound |
◆ cleanupFinishedSounds()
| void cangine::AudioManager::cleanupFinishedSounds |
( |
| ) |
|
|
private |
Removes sounds that have finished playing from memory.
◆ getDuration()
| float cangine::AudioManager::getDuration |
( |
const std::string & |
name | ) |
|
Returns the total duration of a sound.
- Parameters
-
- Returns
- Duration in seconds
◆ getInstance()
◆ getPosition()
| float cangine::AudioManager::getPosition |
( |
const std::string & |
name | ) |
|
Returns the current playback position of a sound.
- Parameters
-
- Returns
- Position in seconds
◆ isPaused()
| bool cangine::AudioManager::isPaused |
( |
const std::string & |
name | ) |
|
Checks whether a sound is currently paused.
- Parameters
-
- Returns
- true if paused, false otherwise
◆ isPlaying()
| bool cangine::AudioManager::isPlaying |
( |
const std::string & |
name | ) |
|
Checks whether a sound is currently playing.
- Parameters
-
- Returns
- true if playing, false otherwise
◆ pause()
| void cangine::AudioManager::pause |
( |
const std::string & |
name | ) |
|
Pauses a sound by name.
- Parameters
-
| name | Name of the sound to pause |
◆ pauseAll()
| void cangine::AudioManager::pauseAll |
( |
| ) |
|
Pauses all currently playing sounds.
◆ play() [1/2]
| void cangine::AudioManager::play |
( |
const Sound & |
sound, |
|
|
bool |
loop = false |
|
) |
| |
Plays a Sound object directly.
- Parameters
-
| sound | Sound object to play |
| loop | Whether to loop the sound |
◆ play() [2/2]
| void cangine::AudioManager::play |
( |
const std::string & |
name, |
|
|
bool |
loop = false |
|
) |
| |
Plays a sound by name.
- Parameters
-
| name | Name of the sound to play |
| loop | Whether to loop the sound |
◆ resume()
| void cangine::AudioManager::resume |
( |
const std::string & |
name | ) |
|
Resumes a paused sound by name.
- Parameters
-
| name | Name of the sound to resume |
◆ resumeAll()
| void cangine::AudioManager::resumeAll |
( |
| ) |
|
Resumes all paused sounds.
◆ seek()
| void cangine::AudioManager::seek |
( |
const std::string & |
name, |
|
|
float |
seconds |
|
) |
| |
Seeks to a specific position in a sound.
- Parameters
-
| name | Name of the sound |
| seconds | Target position in seconds |
◆ setVolume()
| void cangine::AudioManager::setVolume |
( |
const std::string & |
name, |
|
|
float |
volume |
|
) |
| |
Sets the volume of a sound by name.
- Parameters
-
| name | Name of the sound |
| volume | Volume level (0.0 = silent, 1.0 = full) |
◆ setVolumeAll()
| void cangine::AudioManager::setVolumeAll |
( |
float |
volume | ) |
|
Sets the volume of all sounds.
- Parameters
-
| volume | Volume level (0.0 = silent, 1.0 = full) |
◆ stop()
| void cangine::AudioManager::stop |
( |
const std::string & |
name | ) |
|
Stops a sound by name.
- Parameters
-
| name | Name of the sound to stop |
◆ stopAll()
| void cangine::AudioManager::stopAll |
( |
| ) |
|
Stops all currently playing sounds.
◆ activeSounds
| std::vector<std::pair<ma_sound*, std::string> > cangine::AudioManager::activeSounds |
|
private |
Currently active sounds (handle, name)
◆ engine
| ma_engine cangine::AudioManager::engine {} |
|
private |
miniaudio engine instance
◆ initialized
| bool cangine::AudioManager::initialized = false |
|
private |
Whether the engine has been initialized.
◆ instance
◆ sounds
| std::vector<Sound> cangine::AudioManager::sounds |
|
private |
The documentation for this class was generated from the following files: