Planeshift
Public Member Functions | Public Attributes

SoundSystemManager Class Reference

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

#include <manager.h>

List of all members.

Public Member Functions

SoundControlAddSoundControl (uint sndCtrlID)
 Returns a NEW SoundControl.
csVector3 GetListenerPos () const
 Gets the listener position.
csVector3 & GetPlayerPosition ()
 Gets the current player's position.
SoundControlGetSoundControl ()
 Returns a NEW SoundControl.
SoundControlGetSoundControl (uint sndCtrlID) const
SoundDataGetSoundData ()
SoundDataCacheGetSoundDataCache () const
SoundSystemGetSoundSystem ()
SoundSystemGetSoundSystem () const
bool Initialize (iObjectRegistry *objectReg)
 Initializes this SoundSystemManager.
bool IsHandleValid (uint handleID) const
 Check if the given handle ID exists.
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).
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).
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.
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.
void RemoveSoundControl (uint sndCtrlID)
void SetPlayerPosition (csVector3 &pos)
 Sets the current player's position.
void SetPlayerVelocity (csVector3 vel)
 Sets the player velocity.
bool SetSoundSource (uint handleID, csVector3 position)
 Set the position of the sound source of the handle with the given ID.
 SoundSystemManager (iObjectRegistry *objectReg)
 Constructor initializes this SoundSystemManager.
 SoundSystemManager ()
 Constructor.
bool StopSound (uint handleID)
 Pause a sound and set the autoremove.
void StopSound (SoundHandle *handle)
 Stops and removes a SoundHandle.
void Update ()
 Updates this SoundManager and everything its driving.
void Update ()
 Updates this SoundManager and everything its driving.
void UpdateListener (csVector3 v, csVector3 f, csVector3 t)
 Update listener position.
void UpdateListener (csVector3 v, csVector3 f, csVector3 t)
 Update listener position.
void UpdateSound ()
 Checks all SoundHandles alters Volume, does fading, applies the Doppler effect and removes them if Unmanaged (Autoremove true).
void UpdateSound ()
 Checks all SoundHandles alters Volume, does fading and removes them if Unmanaged (Autoremove true).
 ~SoundSystemManager ()
 Destructor will remove everything this SoundManager created.
 ~SoundSystemManager ()
 Destructor will remove everything this SoundManager created.

Public Attributes

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

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, applies the Doppler effect and removes them if Unmanaged (Autoremove true).

void SoundSystemManager::UpdateSound ( )

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


Member Data Documentation

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.

sound control for paws / gui

Definition at line 67 of file manager.h.

is initialized ?

Definition at line 65 of file manager.h.

sound control for this manager

Definition at line 66 of file manager.h.


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