#include <audio.h>
Inheritance diagram for hoa_audio::GameAudio:


Public Member Functions | ||||
| uint32 | CheckErrors () | |||
| Returns a set of error codes and also clears the error code to a no-error state. | ||||
| void | DEBUG_PrintInfo () | |||
| Prints information related to the system's audio capabilities as reported by SDL_mixer. | ||||
| void | PlaySound (std::string filename) | |||
| Plays a sound once. | ||||
| bool | SingletonInitialize () | |||
| A method for the inheriting class to implement, which initializes the class. | ||||
| void | Update () | |||
| Periodically removes any temporarily loaded sounds that have finished playing. | ||||
| ~GameAudio () | ||||
Volume Member Access Functions | ||||
Used for reading and modifying the volume of music/sound in the game. These volume changes have a global effect (they modify the volume of all music/sound sources). There is currently no support to change the volume levels of individual sound or music sources. However, one can achieve the same effect by modifying the source properties and (in the case of single-channel audio) manipulating distance attenuation.
| ||||
| float | GetMusicVolume () | |||
| float | GetSoundVolume () | |||
| void | SetMusicVolume (float vol) | |||
| void | SetSoundVolume (float vol) | |||
Global Music Manipulation Functions | ||||
Performs specified operation on all active music.
Since there is only one music source, these functions only affect that source. They are equivalent to calling the {Pause/Resume/Stop/Rewind}Music functions on the MusicDescriptor which currently has posession of the source. | ||||
| void | PauseAllMusic () | |||
| void | ResumeAllMusic () | |||
| void | RewindAllMusic () | |||
| void | StopAllMusic () | |||
Global Sound Manipulation Functions | ||||
Performs specified operation on all active sounds. | ||||
| void | PauseAllSounds () | |||
| void | ResumeAllSounds () | |||
| void | StopAllSounds () | |||
Global Audio Manipulation Functions | ||||
Performs specified operation on all active sounds and music.
These functions will only effect audio data that is in the state(s) specified below: PauseAudio() <==> playing state ResumeAudio() <==> paused state StopAudio() <==> playing state RewindAudio() <==> playing state, paused state | ||||
| void | PauseAudio () | |||
| void | ResumeAudio () | |||
| void | RewindAudio () | |||
| void | StopAudio () | |||
Private Member Functions | ||||
| GameAudio () | ||||
Audio Data Retrieval Functions | ||||
Creates and loads new audio data if the data is not already loaded.
| ||||
| private_audio::MusicData * | _AcquireMusicData (std::string filename) | |||
| private_audio::SoundData * | _AcquireSoundData (std::string filename) | |||
Private Attributes | ||||
| uint32 | _audio_errors | |||
| Retains all the errors that have occured on audio-related function calls, except for loading errors. | ||||
| float | _music_volume | |||
| The volume level for music playback. Valid range is between 0.0f and 1.0f. | ||||
| float | _sound_volume | |||
| The volume level for sound playback. Valid range is between 0.0f and 1.0f. | ||||
| std::list< SoundDescriptor * > | _temp_sounds | |||
| Holds sounds which are temporarily loaded and played This vector holds any sounds loaded via a call to AudioManager::PlaySound. It will play the sound once to completion. The AudioManager::Update call periodically reviews this list and removes any sounds which have finished playing. | ||||
Audio Data Containers | ||||
Sound (WAV) and music (OGG) data are stored in these container classes and referenced by the SoundDescriptor and MusicDescriptor classes. They are stored in this manner to allow for optimized memory usage (in other words, only one instance of .wav and .ogg data can be loaded in the application at any point in time). The sound or music filename string serves as the map key for determining if the data is loaded or not. The key is a reference to the filename string (which is stored in the SoundData or MusicData class itself). | ||||
| std::map< std::string, private_audio::MusicData * > | _music_data | |||
| std::map< std::string, private_audio::SoundData * > | _sound_data | |||
Friends | ||||
| class | hoa_utils::Singleton< GameAudio > | |||
| class | MusicDescriptor | |||
| class | private_audio::MusicData | |||
| class | private_audio::SoundData | |||
| class | SoundDescriptor | |||
****************************************************************************
This class manages all audio data allocation and manipulation. The OpenAL sources are wrapped inside this class and OpenAL buffers (which are represented by the SoundDescriptor and MusicObject classes) grab these sources as they need them. The buffers are stored in map structures so that audio data is not loaded when it already exists.
2) This audio engine uses smart memory management so that loaded audio data is not re-loaded if the user requests a load operation on the same data. Audio data is only freed once there are no more references to the data.
Definition at line 120 of file audio.h.
| hoa_audio::GameAudio::~GameAudio | ( | ) |
Definition at line 52 of file audio.cpp.
References _music_data, _sound_data, hoa_audio::private_audio::ALL_CHANNELS, and hoa_audio::AUDIO_DEBUG.
| hoa_audio::GameAudio::GameAudio | ( | ) | [private] |
| private_audio::MusicData* hoa_audio::GameAudio::_AcquireMusicData | ( | std::string | filename | ) | [private] |
Referenced by hoa_audio::MusicDescriptor::LoadMusic().
| private_audio::SoundData* hoa_audio::GameAudio::_AcquireSoundData | ( | std::string | filename | ) | [private] |
| uint32 hoa_audio::GameAudio::CheckErrors | ( | ) | [inline] |
Returns a set of error codes and also clears the error code to a no-error state.
This is the standard CheckErrors() function as defined in the Allacrost code standard. The error code constants are listed at the top of this file in the Audio Error Codes group.
Definition at line 139 of file audio.h.
References _audio_errors, and hoa_audio::AUDIO_ERROR_NONE.
| void hoa_audio::GameAudio::DEBUG_PrintInfo | ( | ) |
| float hoa_audio::GameAudio::GetMusicVolume | ( | ) | [inline] |
Definition at line 162 of file audio.h.
References _music_volume.
Referenced by hoa_boot::BootMode::_OnMusicLeft(), hoa_boot::BootMode::_OnMusicRight(), hoa_boot::BootMode::_SaveSettingsFile(), and hoa_boot::BootMode::_UpdateAudioOptions().
| float hoa_audio::GameAudio::GetSoundVolume | ( | ) | [inline] |
Definition at line 164 of file audio.h.
References _sound_volume.
Referenced by hoa_boot::BootMode::_OnSoundLeft(), hoa_boot::BootMode::_OnSoundRight(), hoa_boot::BootMode::_SaveSettingsFile(), and hoa_boot::BootMode::_UpdateAudioOptions().
| void hoa_audio::GameAudio::PauseAllMusic | ( | ) |
| void hoa_audio::GameAudio::PauseAllSounds | ( | ) |
Definition at line 241 of file audio.cpp.
References hoa_audio::private_audio::ALL_CHANNELS.
Referenced by PauseAudio().
| void hoa_audio::GameAudio::PauseAudio | ( | ) |
Definition at line 220 of file audio.cpp.
References PauseAllMusic(), and PauseAllSounds().
Here is the call graph for this function:

| void hoa_audio::GameAudio::PlaySound | ( | std::string | filename | ) |
Plays a sound once.
| filename | The name of the sound file to play |
Referenced by hoa_battle::private_battle::FinishWindow::Update().
| void hoa_audio::GameAudio::ResumeAllMusic | ( | ) |
| void hoa_audio::GameAudio::ResumeAllSounds | ( | ) |
Definition at line 246 of file audio.cpp.
References hoa_audio::private_audio::ALL_CHANNELS.
Referenced by ResumeAudio().
| void hoa_audio::GameAudio::ResumeAudio | ( | ) |
Definition at line 225 of file audio.cpp.
References ResumeAllMusic(), and ResumeAllSounds().
Here is the call graph for this function:

| void hoa_audio::GameAudio::RewindAllMusic | ( | ) |
| void hoa_audio::GameAudio::RewindAudio | ( | ) |
Definition at line 235 of file audio.cpp.
References RewindAllMusic().
Here is the call graph for this function:

| void hoa_audio::GameAudio::SetMusicVolume | ( | float | vol | ) |
Definition at line 182 of file audio.cpp.
References _music_volume, and hoa_audio::AUDIO_DEBUG.
Referenced by hoa_boot::BootMode::_OnMusicLeft(), hoa_boot::BootMode::_OnMusicRight(), and hoa_system::GameSystem::SingletonInitialize().
| void hoa_audio::GameAudio::SetSoundVolume | ( | float | vol | ) |
Definition at line 201 of file audio.cpp.
References _sound_volume, hoa_audio::private_audio::ALL_CHANNELS, and hoa_audio::AUDIO_DEBUG.
Referenced by hoa_boot::BootMode::_OnSoundLeft(), hoa_boot::BootMode::_OnSoundRight(), and hoa_system::GameSystem::SingletonInitialize().
| bool hoa_audio::GameAudio::SingletonInitialize | ( | ) | [virtual] |
A method for the inheriting class to implement, which initializes the class.
Implements hoa_utils::Singleton< T >.
Definition at line 74 of file audio.cpp.
References hoa_audio::AUDIO_DEBUG, hoa_audio::private_audio::BUFFER_SIZE, and hoa_audio::private_audio::SOUND_CHANNELS.
Referenced by InitializeEngine().
| void hoa_audio::GameAudio::StopAllMusic | ( | ) |
Definition at line 275 of file audio.cpp.
References _music_data.
Referenced by hoa_audio::MusicDescriptor::PlayMusic(), and StopAudio().
| void hoa_audio::GameAudio::StopAllSounds | ( | ) |
Definition at line 251 of file audio.cpp.
References hoa_audio::private_audio::ALL_CHANNELS.
Referenced by StopAudio().
| void hoa_audio::GameAudio::StopAudio | ( | ) |
Definition at line 230 of file audio.cpp.
References StopAllMusic(), and StopAllSounds().
Here is the call graph for this function:

| void hoa_audio::GameAudio::Update | ( | ) |
Periodically removes any temporarily loaded sounds that have finished playing.
This method is called once every frame, but it only actually checks for finished sounds once every 5 seconds.
Definition at line 94 of file audio.cpp.
References _temp_sounds, hoa_audio::AUDIO_STATE_STOPPED, hoa_system::GameSystem::GetUpdateTime(), and hoa_system::SystemManager.
Referenced by main().
Here is the call graph for this function:

friend class hoa_utils::Singleton< GameAudio > [friend] |
friend class MusicDescriptor [friend] |
friend class private_audio::MusicData [friend] |
friend class private_audio::SoundData [friend] |
friend class SoundDescriptor [friend] |
uint32 hoa_audio::GameAudio::_audio_errors [private] |
Retains all the errors that have occured on audio-related function calls, except for loading errors.
Definition at line 229 of file audio.h.
Referenced by CheckErrors(), hoa_audio::private_audio::SoundData::DEBUG_PrintProperties(), hoa_audio::private_audio::MusicData::DEBUG_PrintProperties(), hoa_audio::MusicDescriptor::PauseMusic(), hoa_audio::SoundDescriptor::PauseSound(), hoa_audio::SoundDescriptor::PlaySound(), hoa_audio::MusicDescriptor::ResumeMusic(), hoa_audio::SoundDescriptor::ResumeSound(), hoa_audio::MusicDescriptor::RewindMusic(), hoa_audio::MusicDescriptor::SeekMusic(), hoa_audio::MusicDescriptor::StopMusic(), and hoa_audio::SoundDescriptor::StopSound().
std::map<std::string, private_audio::MusicData*> hoa_audio::GameAudio::_music_data [private] |
Definition at line 239 of file audio.h.
Referenced by PauseAllMusic(), ResumeAllMusic(), StopAllMusic(), and ~GameAudio().
float hoa_audio::GameAudio::_music_volume [private] |
The volume level for music playback. Valid range is between 0.0f and 1.0f.
Definition at line 225 of file audio.h.
Referenced by GetMusicVolume(), and SetMusicVolume().
std::map<std::string, private_audio::SoundData*> hoa_audio::GameAudio::_sound_data [private] |
float hoa_audio::GameAudio::_sound_volume [private] |
The volume level for sound playback. Valid range is between 0.0f and 1.0f.
Definition at line 227 of file audio.h.
Referenced by GetSoundVolume(), and SetSoundVolume().
std::list<SoundDescriptor*> hoa_audio::GameAudio::_temp_sounds [private] |
Holds sounds which are temporarily loaded and played This vector holds any sounds loaded via a call to AudioManager::PlaySound. It will play the sound once to completion. The AudioManager::Update call periodically reviews this list and removes any sounds which have finished playing.
Definition at line 264 of file audio.h.
Referenced by Update().
1.5.1