#include <AudioManager.hpp>
Collaboration diagram for BARE2D::AudioManager:Public Member Functions | |
| void | init () |
| Initializes all necessary bits and pieces. More... | |
| void | destroy () |
| Destroys/quits all necessary bits and pieces. More... | |
| unsigned int | playSound (Sound &sound, unsigned int fadeTime=0, unsigned int timeOut=0, int angle=0, unsigned char distance=128) |
| Plays a sound at a position. More... | |
| void | moveSound (unsigned int &soundID, int angle, unsigned char distance=128) |
| Resets the sound's position for positional audio. More... | |
| void | stopSound (unsigned int &soundID, unsigned int fadeTime=0) |
| Stops a sound. More... | |
| void | pauseSound (unsigned int &soundID) |
| Pauses a sound. More... | |
| void | resumeSound (unsigned int &soundID) |
| Resumes a paused sound. More... | |
| void | playMusic (Music &music, unsigned int fadeTime=0) |
| Plays some music! Only one "music" can be played at a time. More... | |
| void | stopMusic (unsigned int fadeTime=0) |
| Stops the music. More... | |
| void | pauseMusic () |
| Pauses the music. More... | |
| void | resumeMusic () |
| Resumes the paused music. More... | |
| void | mute () |
| Mutes all sounds and music. More... | |
| void | unmute () |
| Unmutes all sounds and music. More... | |
| void | setSoundVolume (unsigned char volumeLevel) |
| Sets the volume level of all sounds. More... | |
| void | setMusicVolume (unsigned char volumeLevel) |
| Sets the volume level of all music. More... | |
| void | setMasterVolumeModifier (unsigned char masterLevel) |
| Sets the modifier of all sound levels - eg., if sounds were set at 40% and music at 60%, setting the master modifier to 50% would set sounds to 20% and music to 30%. More... | |
| bool | isMusicPlaying () |
Static Public Member Functions | |
| static AudioManager * | getInstance () |
| static void | release () |
Private Member Functions | |
| AudioManager () | |
| ~AudioManager () | |
Private Attributes | |
| unsigned char | m_soundVolume = 255 |
| unsigned char | m_musicVolume = 255 |
| unsigned char | m_masterVolume = 255 |
| bool | m_muted = false |
Static Private Attributes | |
| static AudioManager * | m_instance = nullptr |
Definition at line 14 of file AudioManager.hpp.
|
private |
Definition at line 28 of file AudioManager.cpp.
Referenced by getInstance().
Here is the caller graph for this function:
|
private |
Definition at line 32 of file AudioManager.cpp.
| void BARE2D::AudioManager::destroy | ( | ) |
Destroys/quits all necessary bits and pieces.
Definition at line 71 of file AudioManager.cpp.
References BARE2D::SDL_MIXER_CLOSE_FAILURE, and BARE2D::throwError().
Referenced by release().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 12 of file AudioManager.cpp.
References AudioManager(), and m_instance.
Here is the call graph for this function:| void BARE2D::AudioManager::init | ( | ) |
Initializes all necessary bits and pieces.
Definition at line 37 of file AudioManager.cpp.
References BARE2D::SDL_MIXER_FLAC_FAILURE, BARE2D::SDL_MIXER_MOD_FAILURE, BARE2D::SDL_MIXER_MP3_FAILURE, BARE2D::SDL_MIXER_OGG_FAILURE, and BARE2D::throwError().
Here is the call graph for this function:| bool BARE2D::AudioManager::isMusicPlaying | ( | ) |
Definition at line 223 of file AudioManager.cpp.
| void BARE2D::AudioManager::moveSound | ( | unsigned int & | soundID, |
| int | angle, | ||
| unsigned char | distance = 128 |
||
| ) |
Resets the sound's position for positional audio.
| soundID | A reference to the ID that represents the sound to move. |
| angle | The angle (clockwise in degrees, where 0 is directly forward) that the sound is to be played at. |
| distance | The distance from the camera that the sound should be played (from 0 (very near, loud) to 255 (very distant, quiet)) |
Definition at line 119 of file AudioManager.cpp.
References utf8::distance(), BARE2D::SDL_MIXER_SOUND_FAILURE, and BARE2D::throwFatalError().
Here is the call graph for this function:| void BARE2D::AudioManager::mute | ( | ) |
Mutes all sounds and music.
Definition at line 179 of file AudioManager.cpp.
References m_musicVolume, m_muted, and m_soundVolume.
| void BARE2D::AudioManager::pauseMusic | ( | ) |
Pauses the music.
Definition at line 169 of file AudioManager.cpp.
| void BARE2D::AudioManager::pauseSound | ( | unsigned int & | soundID | ) |
Pauses a sound.
| soundID | The ID of the sound to pause, given by playSound(...) calls. |
Definition at line 135 of file AudioManager.cpp.
| void BARE2D::AudioManager::playMusic | ( | Music & | music, |
| unsigned int | fadeTime = 0 |
||
| ) |
Plays some music! Only one "music" can be played at a time.
| music | The music to play |
| fadeTime | The number of milliseconds that the sound will take to fade in. Defaults to 0 (no fade). |
Definition at line 145 of file AudioManager.cpp.
References BARE2D::Music::music, BARE2D::SDL_MIXER_SOUND_FAILURE, and BARE2D::throwFatalError().
Here is the call graph for this function:| unsigned int BARE2D::AudioManager::playSound | ( | Sound & | sound, |
| unsigned int | fadeTime = 0, |
||
| unsigned int | timeOut = 0, |
||
| int | angle = 0, |
||
| unsigned char | distance = 128 |
||
| ) |
Plays a sound at a position.
| sound | A reference to the sound that is to be played. |
| fadeTime | The number of milliseconds that the sound will take to fade in. Defaults to 0 (no fade). |
| timeOut | the number of milliseconds before the sound times out. Defaults to 0 (never). |
| angle | The angle (clockwise in degrees, where 0 is directly forward) that the sound is to be played at. Defaults to 0 (directly in front) |
| distance | The distance from the camera that the sound should be played (from 0 (very near, loud) to 255 (very distant, quiet)) |
Definition at line 92 of file AudioManager.cpp.
References BARE2D::Sound::chunk, BARE2D::SDL_MIXER_SOUND_FAILURE, and BARE2D::throwFatalError().
Here is the call graph for this function:
|
static |
Definition at line 20 of file AudioManager.cpp.
References destroy(), and m_instance.
Here is the call graph for this function:| void BARE2D::AudioManager::resumeMusic | ( | ) |
Resumes the paused music.
Definition at line 174 of file AudioManager.cpp.
| void BARE2D::AudioManager::resumeSound | ( | unsigned int & | soundID | ) |
Resumes a paused sound.
| soundID | The ID of the sound to resume, given by playSound(...) calls. |
Definition at line 140 of file AudioManager.cpp.
| void BARE2D::AudioManager::setMasterVolumeModifier | ( | unsigned char | masterLevel | ) |
Sets the modifier of all sound levels - eg., if sounds were set at 40% and music at 60%, setting the master modifier to 50% would set sounds to 20% and music to 30%.
| masterLevel | The level of the volume - 0 is muted, 255 is very loud. |
Definition at line 210 of file AudioManager.cpp.
References m_masterVolume, m_musicVolume, m_soundVolume, setMusicVolume(), and setSoundVolume().
Here is the call graph for this function:| void BARE2D::AudioManager::setMusicVolume | ( | unsigned char | volumeLevel | ) |
Sets the volume level of all music.
| volumeLevel | The level of the volume - 0 is muted, 255 is very loud. |
Definition at line 204 of file AudioManager.cpp.
References m_masterVolume, and m_musicVolume.
Referenced by setMasterVolumeModifier().
Here is the caller graph for this function:| void BARE2D::AudioManager::setSoundVolume | ( | unsigned char | volumeLevel | ) |
Sets the volume level of all sounds.
| volumeLevel | The level of the volume (clamped from 0 (muted) to 255(loud)) |
Definition at line 198 of file AudioManager.cpp.
References m_masterVolume, and m_soundVolume.
Referenced by setMasterVolumeModifier().
Here is the caller graph for this function:| void BARE2D::AudioManager::stopMusic | ( | unsigned int | fadeTime = 0 | ) |
Stops the music.
| fadeTime | The number of milliseconds the sound will take to fade out. Defaults to 0 (no fade). |
Definition at line 160 of file AudioManager.cpp.
| void BARE2D::AudioManager::stopSound | ( | unsigned int & | soundID, |
| unsigned int | fadeTime = 0 |
||
| ) |
Stops a sound.
| fadeTime | The number of milliseconds the sound will take to fade out. Defaults to 0 (no fade). |
| soundID | The ID of the sound to stop, given by playSound(...) calls. |
Definition at line 126 of file AudioManager.cpp.
| void BARE2D::AudioManager::unmute | ( | ) |
Unmutes all sounds and music.
Definition at line 189 of file AudioManager.cpp.
References m_musicVolume, m_muted, and m_soundVolume.
|
staticprivate |
Definition at line 118 of file AudioManager.hpp.
Referenced by getInstance(), and release().
|
private |
Definition at line 120 of file AudioManager.hpp.
Referenced by setMasterVolumeModifier(), setMusicVolume(), and setSoundVolume().
|
private |
Definition at line 120 of file AudioManager.hpp.
Referenced by mute(), setMasterVolumeModifier(), setMusicVolume(), and unmute().
|
private |
Definition at line 121 of file AudioManager.hpp.
|
private |
Definition at line 120 of file AudioManager.hpp.
Referenced by mute(), setMasterVolumeModifier(), setSoundVolume(), and unmute().