Planeshift
SoundSystemManager Class Reference

This Manager Object is used to play all sounds. More...

#include <manager.h>

Public Member Functions

SoundControlAddSoundControl (uint sndCtrlID)
 Returns a NEW SoundControl. More...
 
csVector3 GetListenerPos () const
 Gets the listener position. More...
 
csVector3 & GetPlayerPosition ()
 Gets the current player's position. More...
 
SoundControlGetSoundControl ()
 Returns a NEW SoundControl. More...
 
SoundControlGetSoundControl (uint sndCtrlID) const
 
SoundDataGetSoundData ()
 
SoundDataCacheGetSoundDataCache () const
 
SoundSystemGetSoundSystem ()
 
SoundSystemGetSoundSystem () const
 
bool Initialize (iObjectRegistry *objectReg)
 Initializes this SoundSystemManager. More...
 
bool IsHandleValid (uint handleID) const
 Check if the given handle ID exists. More...
 
bool Play2DSound (const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, SoundHandle *&handle)
 Plays a 2D sound (Cannot be converted to 3D). More...
 
bool Play2DSound (const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, SoundHandle *&handle)
 Plays a 2D sound (Cannot be converted to 3D). More...
 
bool Play3DSound (const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, csVector3 pos, csVector3 dir, float mindist, float maxdist, float rad, int type3d, SoundHandle *&handle)
 Plays a 3D sound. More...
 
bool Play3DSound (const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, csVector3 pos, csVector3 dir, float mindist, float maxdist, float rad, int type3d, SoundHandle *&handle, bool dopplerEffect=true)
 Plays a 3D sound. More...
 
void RemoveSoundControl (uint sndCtrlID)
 
void SetPlayerPosition (csVector3 &pos)
 Sets the current player's position. More...
 
void SetPlayerVelocity (csVector3 vel)
 Sets the player velocity. More...
 
bool SetSoundSource (uint handleID, csVector3 position)
 Set the position of the sound source of the handle with the given ID. More...
 
 SoundSystemManager (iObjectRegistry *objectReg)
 Constructor initializes this SoundSystemManager. More...
 
 SoundSystemManager ()
 Constructor. More...
 
void StopSound (SoundHandle *handle)
 Stops and removes a SoundHandle. More...
 
bool StopSound (uint handleID)
 Pause a sound and set the autoremove. More...
 
void Update ()
 Updates this SoundManager and everything its driving. More...
 
void Update ()
 Updates this SoundManager and everything its driving. More...
 
void UpdateListener (csVector3 v, csVector3 f, csVector3 t)
 Update listener position. More...
 
void UpdateListener (csVector3 v, csVector3 f, csVector3 t)
 Update listener position. More...
 
void UpdateSound ()
 Checks all SoundHandles alters Volume, does fading and removes them if Unmanaged (Autoremove true). More...
 
void UpdateSound ()
 Checks all SoundHandles alters Volume, does fading, applies the Doppler effect and removes them if Unmanaged (Autoremove true). More...
 
 ~SoundSystemManager ()
 Destructor will remove everything this SoundManager created. More...
 
 ~SoundSystemManager ()
 Destructor will remove everything this SoundManager created. More...
 
- Public Member Functions inherited from Singleton< SoundSystemManager >
 Singleton (SoundSystemManager *ptr)
 
 Singleton (void)
 
 ~Singleton ()
 

Public Attributes

SoundControleffectSndCtrl
 sound control for effects / actions More...
 
csRef< iEventTimer > eventTimer
 timer event used by all the sound handle to play after a delay More...
 
SoundControlguiSndCtrl
 sound control for paws / gui More...
 
bool Initialised
 is initialized ? More...
 
SoundControlmainSndCtrl
 sound control for this manager More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< SoundSystemManager >
static SoundSystemManagerGetSingleton (void)
 
static SoundSystemManagerGetSingletonPtr (void)
 

Detailed Description

This Manager Object is used to play all sounds.

It keeps track of Data/Sounds and does fading, sets volume and removes sounds which are no longer needed. You may use the Play*Sound methods to play a sound. You need a

See also
SoundControl and a empty
SoundHandle pointer to play a unmanaged sound. You may discard the Handle or use it the manage your sound. SoundControl and SoundHandle have many Interface functions which help you todo what ever you want. Access to the underlaying sources is also granted.

TODO merge Play* functions

It keeps track of Data/Sounds and does fading, sets volume and removes sounds which are no longer needed. You may use the Play*Sound methods to play a sound. You need a

See also
SoundControl and a empty
SoundHandle pointer to play a unmanaged sound. You may discard the Handle or use it the manage your sound. SoundControl and SoundHandle have many Interface functions which help you todo what ever you want. Access to the underlaying sources is also granted.

Definition at line 62 of file manager.h.

Constructor & Destructor Documentation

SoundSystemManager::SoundSystemManager ( iObjectRegistry *  objectReg)

Constructor initializes this SoundSystemManager.

Also initializes a

See also
SoundSystem and a
SoundData object. Loads soundlib if presend and set Initialised to true or false (based on success) You can always assume that this Interface works. BUT Play*Sound functions will return false if its not Initialised. Be prepared to handle such Error conditions because they may do that at any time (when something goes wrong).
SoundSystemManager::~SoundSystemManager ( )

Destructor will remove everything this SoundManager created.

It will stop and delete all Handles, removes

See also
SoundData and
SoundSystem. All Pointers to objects within this Manager becoming invalid (handles SoundControls etc). Make Sure that you dont use them after destruction.
SoundSystemManager::SoundSystemManager ( )

Constructor.

SoundSystemManager::~SoundSystemManager ( )

Destructor will remove everything this SoundManager created.

It will stop and delete all Handles, removes

See also
SoundDataCache and
SoundSystem. All Pointers to objects within this Manager becoming invalid (handles SoundControls etc). Make Sure that you dont use them after destruction.

Member Function Documentation

SoundControl* SoundSystemManager::AddSoundControl ( uint  sndCtrlID)

Returns a NEW SoundControl.

It creates a new SoundControl and returns it. Also keeps a internal list of all existing SoundControls. But atm there is no way to recover a lost SoundControl.

csVector3 SoundSystemManager::GetListenerPos ( ) const

Gets the listener position.

Returns
the listener position.
csVector3& SoundSystemManager::GetPlayerPosition ( )

Gets the current player's position.

Returns
the player's position.
SoundControl* SoundSystemManager::GetSoundControl ( )

Returns a NEW SoundControl.

It creates a new SoundControl and returns it. Also keeps a internal list of all existing SoundControls. But atm there is no way to recover a lost SoundControl.

SoundControl* SoundSystemManager::GetSoundControl ( uint  sndCtrlID) const
SoundData* SoundSystemManager::GetSoundData ( )
inline

Definition at line 158 of file manager.h.

SoundDataCache* SoundSystemManager::GetSoundDataCache ( ) const
inline

Definition at line 225 of file manager.h.

SoundSystem* SoundSystemManager::GetSoundSystem ( )
inline

Definition at line 157 of file manager.h.

SoundSystem* SoundSystemManager::GetSoundSystem ( ) const
inline

Definition at line 224 of file manager.h.

bool SoundSystemManager::Initialize ( iObjectRegistry *  objectReg)

Initializes this SoundSystemManager.

Also initializes a

See also
SoundSystem and a
SoundDataCache object. Loads soundlib if presend and set Initialised to true or false (based on success)
Parameters
objectRegthe object registry.
Returns
true if initialization is successful, false otherwise.
bool SoundSystemManager::IsHandleValid ( uint  handleID) const

Check if the given handle ID exists.

Parameters
handleIDthe handle ID to check.
bool SoundSystemManager::Play2DSound ( const char *  name,
bool  loop,
size_t  loopstart,
size_t  loopend,
float  volume_preset,
SoundControl *&  sndCtrl,
SoundHandle *&  handle 
)

Plays a 2D sound (Cannot be converted to 3D).

Parameters
namename of the resource you want to play
See also
SoundData for details
Parameters
loopLOOP or DONT_LOOP
loopstartstartframe when looping
loopendwhen reach it will jump to startframe
volume_presetvolume for this sound, all volume calculations are based upon this
sndCtrlSoundControl to control this sound
handlea Handle you have to supply. You may discard it if you dont want to manage this sound.
bool SoundSystemManager::Play2DSound ( const char *  name,
bool  loop,
size_t  loopstart,
size_t  loopend,
float  volume_preset,
SoundControl *&  sndCtrl,
SoundHandle *&  handle 
)

Plays a 2D sound (Cannot be converted to 3D).

Parameters
namename of the resource you want to play
See also
SoundDataCache for details
Parameters
loopLOOP or DONT_LOOP
loopstartstartframe when looping
loopendwhen reach it will jump to startframe
volume_presetvolume for this sound, all volume calculations are based upon this
sndCtrlSoundControl to control this sound
handlea Handle you have to supply. If the handle is null a new one is created. You may discard it if you dont want to manage this sound.
Returns
true if the handle could be played, false otherwise.
bool SoundSystemManager::Play3DSound ( const char *  name,
bool  loop,
size_t  loopstart,
size_t  loopend,
float  volume_preset,
SoundControl *&  sndCtrl,
csVector3  pos,
csVector3  dir,
float  mindist,
float  maxdist,
float  rad,
int  type3d,
SoundHandle *&  handle 
)

Plays a 3D sound.

Parameters
namename of the resource you want to play
See also
SoundData for details
Parameters
loopLOOP or DONT_LOOP
loopstartstartframe when looping
loopendwhen reach it will jump to startframe
volume_presetvolume for this sound, all volume calculations are based upon this
sndCtrlthe sound controller
posSound 3d position of the sound, keep type3d in mind because it can be ABSOLUTE or RELATIVE
dirdirection this sound is emitting to
mindistdistance when maxvolume should be reached
maxdistdistance when minvolume is applied
radradiation of the directional cone. Set it to 0 if you dont want a directional sound.
type3dEither ABSOLUTE or RELATIVE.
handlea Handle you have to supply. You may discard it if you dont want to manage this sound.
bool SoundSystemManager::Play3DSound ( const char *  name,
bool  loop,
size_t  loopstart,
size_t  loopend,
float  volume_preset,
SoundControl *&  sndCtrl,
csVector3  pos,
csVector3  dir,
float  mindist,
float  maxdist,
float  rad,
int  type3d,
SoundHandle *&  handle,
bool  dopplerEffect = true 
)

Plays a 3D sound.

Parameters
namename of the resource you want to play
See also
SoundDataCache for details
Parameters
loopLOOP or DONT_LOOP
loopstartstartframe when looping
loopendwhen reach it will jump to startframe
volume_presetvolume for this sound, all volume calculations are based upon this
posSound 3d position of the sound, keep type3d in mind because it can be ABSOLUTE or RELATIVE
dirdirection this sound is emitting to
mindistdistance when maxvolume should be reached
maxdistdistance when minvolume is applied
radradiation of the directional cone. Set it to 0 if you dont want a directional sound.
handlea Handle you have to supply. If the handle is null a new one is created. You may discard it if you dont want to manage this sound.
dopplerEffecttrue to apply the doppler effect to this sound, false otherwise.
Returns
true if the handle could be played, false otherwise.
void SoundSystemManager::RemoveSoundControl ( uint  sndCtrlID)
void SoundSystemManager::SetPlayerPosition ( csVector3 &  pos)

Sets the current player's position.

Parameters
posthe new player's position.
void SoundSystemManager::SetPlayerVelocity ( csVector3  vel)

Sets the player velocity.

Parameters
velthe player's velocity.
bool SoundSystemManager::SetSoundSource ( uint  handleID,
csVector3  position 
)

Set the position of the sound source of the handle with the given ID.

Parameters
handleIDthe ID of the handle to stop.
positionthe new position of the sound's source.
Returns
true if the handle exists, false otherwise.
void SoundSystemManager::StopSound ( SoundHandle handle)

Stops and removes a SoundHandle.

Use with caution. It doesnt care if its still in use.

Parameters
handleA valid soundhandle
bool SoundSystemManager::StopSound ( uint  handleID)

Pause a sound and set the autoremove.

The handle is picked up in the next update.

Parameters
handleIDthe ID of the handle to stop.
Returns
true if the handle exists, false otherwise.
void SoundSystemManager::Update ( )

Updates this SoundManager and everything its driving.

Consider this as its Mainloop. It does ten updates per second. It calls UpdateSound and updates SoundData.

void SoundSystemManager::Update ( )

Updates this SoundManager and everything its driving.

Consider this as its Mainloop. It does ten updates per second. It calls UpdateSound and updates SoundDataCache.

void SoundSystemManager::UpdateListener ( csVector3  v,
csVector3  f,
csVector3  t 
)

Update listener position.

Parameters
vviewpoint or for that matter hearpoint
ffront
ttop
void SoundSystemManager::UpdateListener ( csVector3  v,
csVector3  f,
csVector3  t 
)

Update listener position.

Parameters
vviewpoint or for that matter hearpoint
ffront
ttop
void SoundSystemManager::UpdateSound ( )

Checks all SoundHandles alters Volume, does fading and removes them if Unmanaged (Autoremove true).

void SoundSystemManager::UpdateSound ( )

Checks all SoundHandles alters Volume, does fading, applies the Doppler effect and removes them if Unmanaged (Autoremove true).

Member Data Documentation

SoundControl* SoundSystemManager::effectSndCtrl

sound control for effects / actions

Definition at line 68 of file manager.h.

csRef<iEventTimer> SoundSystemManager::eventTimer

timer event used by all the sound handle to play after a delay

Definition at line 85 of file manager.h.

SoundControl* SoundSystemManager::guiSndCtrl

sound control for paws / gui

Definition at line 67 of file manager.h.

bool SoundSystemManager::Initialised

is initialized ?

Definition at line 65 of file manager.h.

SoundControl * SoundSystemManager::mainSndCtrl

sound control for this manager

Definition at line 66 of file manager.h.


The documentation for this class was generated from the following file: