![]() |
My Project
|
Class that handle the OpenAL audio. More...
#include <AnnAudioEngine.hpp>
Public Member Functions | |
AnnAudioEngine () | |
class constructor More... | |
~AnnAudioEngine () | |
class destructor More... | |
bool | initOpenAL () |
init OpenAL More... | |
void | shutdownOpenAL () |
shutdown and cleanup OpenAL More... | |
ALuint | loadBuffer (const std::string &filename) |
void | preLoadBuffer (const std::string &filename) |
ALuint | isBufferLoader (const std::string &filename) |
Return "false" if buffer not loaded. Return buffer index if buffer is loaded. More... | |
void | unloadBuffer (const std::string &filename) |
void | playBGM (const std::string &filename, float volume=0.5f) |
void | stopBGM () const |
stop the current background music from playing More... | |
std::string | getLastError () const |
Get the last error message that occurred in-engine. More... | |
AnnAudioSourcePtr | createSource () |
Create an audio source. More... | |
AnnAudioSourcePtr | createSource (std::string name) |
Create an audio source and attach (and load if necessary) buffer from audio file. More... | |
void | removeSource (AnnAudioSourcePtr source) |
Remove an audio source frop the engine. More... | |
void | logError () const |
Write last error text to the log. More... | |
![]() | |
AnnSubSystem (const std::string &systemName) | |
Construct a SubSystem. More... | |
virtual | ~AnnSubSystem () |
Destruct a SubSystem. More... | |
Private Member Functions | |
void | updateListenerPos (AnnVect3 pos) |
void | update () override |
Update the subsystem : set the listener position. More... | |
void | detectPlaybackDevices (const char *list) |
Detect playback devices from the device enumeration string. More... | |
Static Private Member Functions | |
static void | updateListenerOrient (AnnQuaternion orient) |
Private Attributes | |
std::string | lastError |
The last error this class has generated. More... | |
ALCdevice * | alDevice |
AL alDevice. More... | |
ALCcontext * | alContext |
AL Context. More... | |
ALuint | bgmBuffer |
Audio buffer for background music. More... | |
ALuint | bgmSource |
Audio source for background music. More... | |
std::unordered_map< std::string, ALuint > | buffers |
Map between audio filenames and OpenAL buffer. More... | |
bool | locked |
Prevent some operation if set to true. More... | |
std::list< AnnAudioSourcePtr > | audioSources |
List of the audio sources object present in the audio engine. More... | |
std::vector< std::string > | detectedDevices |
List of audio device names. More... | |
AnnAudioFileManager * | audioFileManager |
Custom Ogre resource manager that loads binary files used to load audio files. More... | |
Friends | |
class | AnnEngine |
For engine : update listener Orientation. More... | |
Additional Inherited Members | |
![]() | |
virtual bool | needUpdate () |
To be called by AnnEngine : Return if the subsystem wants to be updated. More... | |
![]() | |
std::string | name |
Name of the subsystem. More... | |
Class that handle the OpenAL audio.
Definition at line 82 of file AnnAudioEngine.hpp.
AnnAudioEngine::AnnAudioEngine | ( | ) |
class constructor
Definition at line 11 of file AnnAudioEngine.cpp.
AnnAudioEngine::~AnnAudioEngine | ( | ) |
class destructor
Definition at line 48 of file AnnAudioEngine.cpp.
std::shared_ptr< AnnAudioSource > AnnAudioEngine::createSource | ( | ) |
Create an audio source.
Definition at line 371 of file AnnAudioEngine.cpp.
std::shared_ptr< AnnAudioSource > AnnAudioEngine::createSource | ( | std::string | name | ) |
Create an audio source and attach (and load if necessary) buffer from audio file.
Definition at line 359 of file AnnAudioEngine.cpp.
|
private |
Detect playback devices from the device enumeration string.
Definition at line 56 of file AnnAudioEngine.cpp.
std::string AnnAudioEngine::getLastError | ( | ) | const |
Get the last error message that occurred in-engine.
Definition at line 354 of file AnnAudioEngine.cpp.
bool AnnAudioEngine::initOpenAL | ( | ) |
init OpenAL
Definition at line 78 of file AnnAudioEngine.cpp.
ALuint AnnAudioEngine::isBufferLoader | ( | const std::string & | filename | ) |
Return "false" if buffer not loaded. Return buffer index if buffer is loaded.
Definition at line 175 of file AnnAudioEngine.cpp.
ALuint AnnAudioEngine::loadBuffer | ( | const std::string & | filename | ) |
Load a sound file. return a sound buffer. Add the buffer to the buffer list. This permit to pre-load sound files to the engine. If want to avoid loading a Bunch of sound file (that causes disk I/O access) you can just load the sound file before the start of your gameplay sequence.
filename | Name of the file you want to load |
Definition at line 183 of file AnnAudioEngine.cpp.
void AnnAudioEngine::logError | ( | ) | const |
Write last error text to the log.
Definition at line 43 of file AnnAudioEngine.cpp.
void AnnAudioEngine::playBGM | ( | const std::string & | filename, |
float | volume = 0.5f |
||
) |
play background music. you can specify the volume of the music (0.0f to 1.0f)
filename | name of the audio file to use as background music |
volume | Float number between 0 and 1, Loudness of the sound. At 0.5f by default |
Definition at line 303 of file AnnAudioEngine.cpp.
void AnnAudioEngine::preLoadBuffer | ( | const std::string & | filename | ) |
This method is intended to be used in moments like loading levels If a buffer is already loaded, getting it with loadBuffer is equivalent at getting something from an unordered map. If loadBuffer is called with a "new" sound file, the engine will load it in memory before doing anything else, delaying stuff because of disk I/O Load a sound file. return a sound buffer. Add the buffer to the buffer list. This permit to pre-load sound files to the engine. If want to avoid loading a Bunch of sound file (that causes disk I/O access) you can just load the sound file before the start of your gameplay sequence.
filename | Name of the file you want to load |
Definition at line 170 of file AnnAudioEngine.cpp.
void AnnAudioEngine::removeSource | ( | AnnAudioSourcePtr | source | ) |
Remove an audio source frop the engine.
Definition at line 366 of file AnnAudioEngine.cpp.
void AnnAudioEngine::shutdownOpenAL | ( | ) |
shutdown and cleanup OpenAL
Definition at line 144 of file AnnAudioEngine.cpp.
void AnnAudioEngine::stopBGM | ( | ) | const |
stop the current background music from playing
Definition at line 319 of file AnnAudioEngine.cpp.
void AnnAudioEngine::unloadBuffer | ( | const std::string & | filename | ) |
Unload a buffer from the engine. The buffer is identified by the sound file it represent
filename | Path of the file you want to load |
Definition at line 279 of file AnnAudioEngine.cpp.
|
overrideprivatevirtual |
Update the subsystem : set the listener position.
Reimplemented from Annwvyn::AnnSubSystem.
Definition at line 347 of file AnnAudioEngine.cpp.
|
staticprivate |
For the engine : update the listener orientation to match the player's head
orient | The orientation of the player |
Definition at line 337 of file AnnAudioEngine.cpp.
|
private |
For the engine: update the listener position to match the player's head
pos | The position of the player |
Definition at line 325 of file AnnAudioEngine.cpp.
|
friend |
For engine : update listener Orientation.
Definition at line 152 of file AnnAudioEngine.hpp.
|
private |
AL Context.
Definition at line 165 of file AnnAudioEngine.hpp.
|
private |
AL alDevice.
Definition at line 163 of file AnnAudioEngine.hpp.
|
private |
Custom Ogre resource manager that loads binary files used to load audio files.
Definition at line 183 of file AnnAudioEngine.hpp.
|
private |
List of the audio sources object present in the audio engine.
Definition at line 178 of file AnnAudioEngine.hpp.
|
private |
Audio buffer for background music.
Definition at line 168 of file AnnAudioEngine.hpp.
|
private |
Audio source for background music.
Definition at line 170 of file AnnAudioEngine.hpp.
|
private |
Map between audio filenames and OpenAL buffer.
Definition at line 173 of file AnnAudioEngine.hpp.
|
private |
List of audio device names.
Definition at line 181 of file AnnAudioEngine.hpp.
|
private |
The last error this class has generated.
Definition at line 161 of file AnnAudioEngine.hpp.
|
private |
Prevent some operation if set to true.
Definition at line 176 of file AnnAudioEngine.hpp.