Class for managing audio.
More...
#include <AudioManager.h>
Class for managing audio.
This class allows us to play multiple audio files at the same time. This class can play multiple sound effects at the same time as one music file. Playing another music file while there is a music file playing will replace it. Each audio file is played in a separate thread
- See also
- Music and SoundEffect
Definition at line 56 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 maximum volume for all audio players.
- Parameters
-
This function will add/subtract to/from the current volume
- See also
- setMasterVolume
◆ getMasterVolume()
float ime::audio::AudioManager::getMasterVolume |
( |
| ) |
const |
Get the maximum volume for all audio players.
- Returns
- The maximum volume for all audio players
◆ getVolumeFor()
float ime::audio::AudioManager::getVolumeFor |
( |
Type |
audioType | ) |
const |
Get the volume of an audio type.
- Parameters
-
audioType | Type of the audio to get volume for |
- Returns
- The volume for a given audio type
◆ onMute()
void ime::audio::AudioManager::onMute |
( |
Callback< bool > |
callback | ) |
|
Add an event listener to a mute event.
- Parameters
-
callback | Function to execute when mute state changes |
◆ onVolumeChanged()
void ime::audio::AudioManager::onVolumeChanged |
( |
Callback< float > |
callback | ) |
|
Add an event listener to a volume change event.
- Parameters
-
callback | Function to execute when volume changes |
◆ operator=() [1/2]
Move assignment operator.
◆ operator=() [2/2]
Copy assignment operator.
◆ pauseAllAudio()
void ime::audio::AudioManager::pauseAllAudio |
( |
| ) |
|
Pause all playing audio files.
◆ play()
void ime::audio::AudioManager::play |
( |
Type |
audioType, |
|
|
const std::string & |
filename, |
|
|
bool |
isLooped = false |
|
) |
| |
Play an audio file.
- Parameters
-
audioType | Type of the audio file to play |
filename | Filename of the audio to play |
isLooped | True if audio should be looped, otherwise false |
- Exceptions
-
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.
◆ playAllAudio()
void ime::audio::AudioManager::playAllAudio |
( |
| ) |
|
Play all paused/stopped audio files.
◆ removePlayedAudio()
void ime::audio::AudioManager::removePlayedAudio |
( |
| ) |
|
Remove audio that has finished playing.
The number of audio that played and stopped must not be left to reach 255, otherwise an error would occur and audio will stop playing
◆ setMasterVolume()
void ime::audio::AudioManager::setMasterVolume |
( |
float |
volume | ) |
|
Set the maximum volume for all audio types.
- Parameters
-
volume | The new maximum volume |
This function will overwrite the previous volume The maximum volume for all audio players is 100 by default
- See also
- adjustMasterVolume
◆ setMute()
void ime::audio::AudioManager::setMute |
( |
bool |
isMuted | ) |
|
Mute or unmute all audio players.
- Parameters
-
isMuted | True to mute all audio, otherwise false |
◆ setVolumeFor()
void ime::audio::AudioManager::setVolumeFor |
( |
Type |
audioType, |
|
|
float |
volume |
|
) |
| |
Set the volume for an audio type.
- Parameters
-
audioType | Type of the audio file to set volume for |
volume | Volume to set, in the range (mute) 0 <= volume <= 100 (max) |
The default volume is 100 (max) for all audio types
◆ stopAllAudio()
void ime::audio::AudioManager::stopAllAudio |
( |
| ) |
|
Stop all playing audio files.
Stopping an audio file (playing/paused) will reset the current playing position to the beginning
The documentation for this class was generated from the following file: