Public Methods |
virtual void | shutdown () |
bool | initialized () |
| Return a pointer to the singleton object Returns true if the SoundManager is initalized. More...
|
bool | pushSoundEvent (SoundState *state, unsigned int priority=0) |
openalpp::Sample * | SoundManager::getSample (const std::string &path, bool add_to_cache=true) |
void | SoundManager::clearSampleCache (void) |
openalpp::Stream * | SoundManager::getStream (const std::string &path, bool add_to_cache=true) |
void | SoundManager::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. More...
|
void | update () |
openalpp::Listener * | getListener () |
| Return a pointer to the listener. More...
|
openalpp::AudioEnvironment * | getEnvironment () |
| Return a pointer to the Sound environment. More...
|
void | addSoundState (osgAL::SoundState *state) |
bool | removeSoundState (const std::string &id) |
| Removes the sound state from the list of existing soundstates. More...
|
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. More...
|
const osg::Matrix & | getListenerMatrix () const |
| Return the current listener matrix. More...
|
openalpp::Source * | allocateSource (unsigned int priority, bool mutual_use=true) |
void | setMaxVelocity (float vel) |
| Set the maximum velocity used in doppler calculation. More...
|
float | getMaxVelocity () const |
| Returns the maximum velocity used in doppler calculation. More...
|
void | setFilePathEnvironmentVariable (const std::string &env) |
void | addFilePath (const std::string &path) |
unsigned int | getNumAvailableSources () |
unsigned int | getNumSources () |
unsigned int | getNumActiveSources () |
Static Public Methods |
SoundManager * | instance (void) |
| Return the singleton object. More...
|
Private Types |
typedef std::map< std::string,
openalpp::ref_ptr< openalpp::Sample > > | SampleMap |
typedef SampleMap::iterator | SampleMapIterator |
typedef SampleMap::value_type | SampleMapValType |
typedef std::map< std::string,
openalpp::ref_ptr< openalpp::FileStream > > | StreamMap |
typedef StreamMap::iterator | StreamMapIterator |
typedef StreamMap::value_type | StreamMapValType |
typedef std::vector< openalpp::ref_ptr<
openalpp::Source > > | SourceVector |
typedef std::vector< std::pair<
unsigned int, openalpp::ref_ptr<
openalpp::Source > > > | ActiveSourceVector |
typedef std::map< std::string,
osg::ref_ptr< SoundState > > | SoundStateMap |
typedef std::priority_queue<
SoundStateQueueItem > | SoundStateQueue |
typedef std::vector< osg::ref_ptr<
SoundState > > | SoundStateVector |
Private Methods |
openalpp::Source * | getSource (unsigned int priority, bool registrate_as_active=true, int depth=0) |
| ~SoundManager () |
| Destructor. More...
|
| SoundManager (void) |
| Default Constructor. More...
|
void | resetSource (openalpp::Source *source) |
Private Attributes |
osg::ref_ptr< SoundStateFlyWeight > | m_sound_state_FlyWeight |
SampleMap | m_sample_cache |
StreamMap | m_stream_cache |
openalpp::ref_ptr< openalpp::Listener > | m_listener |
openalpp::ref_ptr< openalpp::AudioEnvironment > | m_sound_environment |
ActiveSourceVector | m_active_soundsources |
SourceVector | m_soundsources |
osg::Matrix | m_listener_matrix |
SourceVector | m_available_soundsources |
SoundStateMap | m_sound_states |
SoundStateQueue | m_sound_state_queue |
SoundStateVector | m_active_sound_states |
bool | m_initialized |
osg::Vec3 | m_last_pos |
float | m_max_velocity |
osg::Timer | m_timer |
osg::Timer_t | m_last_tick |
bool | m_first_run |
FilePathContainer | m_filepathcontainer |
osg::Vec3 | m_listener_direction |
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.