Manages audio playback.
More...
#include <AudioManager.h>
Manages audio playback.
Definition at line 47 of file AudioManager.h.
◆ AudioManager() [1/3]
ime::audio::AudioManager::AudioManager |
( |
| ) |
|
◆ AudioManager() [2/3]
ime::audio::AudioManager::AudioManager |
( |
const AudioManager & |
| ) |
|
|
delete |
◆ AudioManager() [3/3]
◆ adjustMasterVolume()
void ime::audio::AudioManager::adjustMasterVolume |
( |
float |
offset | ) |
|
Offset the master volume.
- Parameters
-
offset | The value to offset the volume by |
A positive offset increases the master volume whilst a negative offset decreases it. Note that the master volume cannot be lower that zero (min) or higher than 100 (max)
- See also
- setMasterVolume
◆ getMasterVolume()
float ime::audio::AudioManager::getMasterVolume |
( |
| ) |
const |
◆ getVolumeFor()
float ime::audio::AudioManager::getVolumeFor |
( |
Type |
audioType | ) |
const |
Get the volume of an audio type.
- Parameters
-
audioType | The audio type to get the volume for |
- Returns
- The current volume for audio files of the specified type
◆ onMute()
void ime::audio::AudioManager::onMute |
( |
Callback< bool > |
callback | ) |
|
Add an event listener to a mute event.
- Parameters
-
callback | Function to be executed audio is muted or unmuted |
◆ onVolumeChanged()
void ime::audio::AudioManager::onVolumeChanged |
( |
Callback< float > |
callback | ) |
|
Add an event listener to a master volume change event.
- Parameters
-
callback | Function to be executed when the master volume changes |
◆ operator=() [1/2]
Move assignment operator.
◆ operator=() [2/2]
Copy assignment operator.
◆ pauseAll()
void ime::audio::AudioManager::pauseAll |
( |
| ) |
|
◆ play()
Audio * ime::audio::AudioManager::play |
( |
Type |
audioType, |
|
|
const std::string & |
filename |
|
) |
| |
Play an audio file.
- Parameters
-
audioType | Type of the audio file to play |
filename | The filename of the audio to play |
- Exceptions
-
- Returns
- Pointer to the audio file after it starts playing
The audio files are played in a separate thread. This means that, the main thread is not blocked and other audio file may be played simultaneously.
Note that the returned pointer may be used to manipulate properties of the audio file such as volume, pitch, loop state etc. However, it must not be kept alive as it will be invalidated when the audio file stops playing. Trying to access the audio file after it has stopped playing is undefined behavior
◆ playAll()
void ime::audio::AudioManager::playAll |
( |
| ) |
|
◆ setMasterVolume()
void ime::audio::AudioManager::setMasterVolume |
( |
float |
volume | ) |
|
Set the maximum volume for all audio types.
- Parameters
-
volume | The new maximum volume |
By default, the maximum volume for all audio types is 100 (max)
- See also
- adjustMasterVolume
◆ setMute()
void ime::audio::AudioManager::setMute |
( |
bool |
isMuted | ) |
|
Mute or unmute all audio.
- Parameters
-
isMuted | True to mute all audio, otherwise false |
◆ setVolume()
void ime::audio::AudioManager::setVolume |
( |
Type |
audioType, |
|
|
float |
volume |
|
) |
| |
Set the volume for an audio type.
- Parameters
-
audioType | The audio type to set the volume for |
volume | Volume to set, in the range 0 <= volume <= 100 where 0 is mute and 100 is maximum volume |
The default volume is 100 (max) for all audio types
◆ stopAll()
void ime::audio::AudioManager::stopAll |
( |
| ) |
|
Stop all playing audio files.
- Warning
- When an audio file is stopped (explicitly or when it reaches the end of its playback), it automatically gets removed from the audio manager. This invalidates all pointers to the audio instance
The documentation for this class was generated from the following file: