Public Member Functions | |
virtual void | shutdown () |
bool | initialized () |
Returns true if the SoundManager is initalized. | |
bool | pushSoundEvent (SoundState *state, unsigned int priority=0) |
openalpp::Sample * | getSample (const std::string &path, bool add_to_cache=true) |
void | clearSampleCache (void) |
openalpp::Stream * | getStream (const std::string &path, bool add_to_cache=true) |
void | clearStreamCache (void) |
SoundState * | findSoundState (const std::string &id) |
void | releaseSource (openalpp::Source *source) |
void | init (unsigned int num_soundsources, float sound_velocity=343) |
Initializes the SoundManager. | |
void | update () |
openalpp::Listener * | getListener () |
Return a pointer to the listener. | |
openalpp::AudioEnvironment * | getEnvironment () |
Return a pointer to the Sound environment. | |
void | addSoundState (osgAL::SoundState *state) |
bool | removeSoundState (const std::string &id) |
Removes the sound state from the list of existing soundstates. | |
bool | removeSoundState (osgAL::SoundState *state) |
void | setListenerDirection (const osg::Vec3 &dir) |
const osg::Vec3 & | getListenerDirection () const |
void | setListenerMatrix (const osg::Matrix &matrix) |
Set the transformation matrix for the listener. | |
const osg::Matrix & | getListenerMatrix () const |
Return the current listener matrix. | |
openalpp::Source * | allocateSource (unsigned int priority, bool mutual_use=true) |
void | setMaxVelocity (float vel) |
Set the maximum velocity used in doppler calculation. | |
float | getMaxVelocity () const |
Returns the maximum velocity used in doppler calculation. | |
unsigned int | getNumAvailableSources () |
unsigned int | getNumSources () |
unsigned int | getNumActiveSources () |
void | setClampVelocity (bool c) |
Set if the velocity is clamped (using the MaxVelocity attribute). | |
bool | getClampVelocity () |
Get true if the velocity is clamped (using the MaxVelocity attribute). | |
const bool | getClampVelocity () const |
Get const true if the velocity is clamped (using the MaxVelocity attribute). | |
void | setUpdateFrequency (float frequency) |
Set the update frequency for both sources and listener, to update pos, dir and occlusions. | |
float | getUpdateFrequency () |
Get the update frequency for both sources and listener, to update pos, dir and occlusions. | |
const float | getUpdateFrequency () const |
Get const the update frequency for both sources and listener, to update pos, dir and occlusions. | |
Static Public Member Functions | |
static SoundManager * | instance (void) |
Return the singleton object. | |
Classes | |
class | SoundStateFlyWeight |
Class that handles all the soundstates. See FlyWeight Design pattern. | |
class | SoundStateQueueItem |
This class initialises the Sound system. It also keeps track of loaded sound samples. It is based on the Singleton Design pattern. To manage a limited resource of Sound sources (which is usually around 32) a schema has to be set up.
This class initially initializes sound sources and places them into a pool of available sources. Whenever someone calls allocateSource() the sound manager tries to free a source and return a pointer to it. If there are no sources available it goes through the active sources and tries to find one with a lower priority. If it still fails, an exception is thrown. Otherwise the found source is returned.
The allocateSource() has an argument indicating that if the source should be placed in the list of active sources. If this argument is false, the caller is responsible to call releaseSource() when finished using the source.
SoundManager also handles SoundStates. Whenever pushSoundEvent() is called, a FlyWeight set of SoundStates is inquired for a free SoundState. The argument of pushSoundEvent() is copied to the free SoundState and that SoundState is then pushed to the queue of waiting SoundStates.
When SoundManager::update() is called, the queue of waiting SoundStates is inquired and for each SoundState a Source is allocated. When the SoundManager realizes that a SoundState is not playing anymore, it is removed from the list of active SoundStates and put back in to the FlyWeight set of available SoundStates.
|
Add a SoundState to the list of existing sound states |
|
Tries to find an available sound Source
|
|
Clear the sample cache with all loaded samples. |
|
Clear the Stream cache with all loaded streams. |
|
Return a pointer to the SoundState with the name id.
|
|
Get const true if the velocity is clamped (using the MaxVelocity attribute).
|
|
Get true if the velocity is clamped (using the MaxVelocity attribute).
|
|
Return a pointer to the Sound environment.
|
|
Return a pointer to the listener.
|
|
|
|
Return the current listener matrix.
|
|
Returns the maximum velocity used in doppler calculation.
|
|
Returns the number of SoundSources currently in use. Should be between 0..getNumSources() |
|
Returns the number of free and available SoundSoures for allocation. Should be between 0 .. getNumSources() |
|
Returns the number of initialized SoundSources. Should be between 0.. |
|
Return a pointer to a Sample. Each Sample will be stored in a cache with its associated path (if add_to_cache is true) Each call to getSample will first look in the cache and try to find the path there. If it can be found, it will return to that Sample. Otherwise it will be loaded from disk. |
|
Return a pointer to a Stream Each Stream will be stored in a cache with its associated path. Each call to getStream will first look in the cache and try to find the path there. If it can be found, it will return to that Stream. Otherwise it will be loaded from disk. |
|
Get const the update frequency for both sources and listener, to update pos, dir and occlusions.
|
|
Get the update frequency for both sources and listener, to update pos, dir and occlusions.
|
|
Initializes the SoundManager.
|
|
Returns true if the SoundManager is initalized.
|
|
Return the singleton object.
|
|
Push a SoundState to the queue of waiting SoundStates When the update method later on is called, this queue is inquired and each waiting SoundEvent will be put in the active state and put to a list of active SoundStates with a Source allocated.
|
|
Puts the source into the list of available sound sources |
|
Removes the sound state from the list of existing soundstates |
|
Removes the sound state from the list of existing soundstates.
|
|
Set if the velocity is clamped (using the MaxVelocity attribute).
|
|
To make it possible to flip left and right ear for the listner this vector specified will be multiplied with the up vector everytime the orientation of the listener is calculated The default value is (1, 1, 1). Make sure not to set anyone to zero, this will be caught and an exception will be thrown. |
|
Set the transformation matrix for the listener.
|
|
Set the maximum velocity used in doppler calculation.
|
|
Set the update frequency for both sources and listener, to update pos, dir and occlusions.
|
|
Deallocates any allocated memory, this method have to be called prior to the end of main() OpenAL doesnt like destruction of sources outside the main() function. |
|
|