Planeshift
Public Member Functions | Public Attributes | Protected Attributes

SoundHandle Class Reference

#include <handle.h>

List of all members.

Public Member Functions

void ConvertTo3D (float mindist, float maxdist, csVector3 pos, csVector3 dir, float rad)
 Converts this Handle to a 3D Handle.
void ConvertTo3D (float mindist, float maxdist, csVector3 pos, csVector3 dir, float rad)
 Converts this Handle to a 3D Handle.
void Fade (float volume, int time, int direction)
 Does fading calculation for this Handle.
void Fade (float volume, int time, int direction)
 Does fading calculation for this Handle.
void FadeStep ()
 Perform a fading step if it is needed.
bool GetAutoRemove ()
 Returns state of AutoRemove.
bool GetAutoRemove ()
 Returns state of AutoRemove.
uint GetID () const
 Gets the ID of this handle.
csVector3 GetSourcePosition ()
 Gets the position of the source.
bool Init (const char *resname, bool loop, float volume_preset, int type, SoundControl *&ctrl)
 Initialize this Handle.
virtual bool Init (const char *resname, bool loop, float volume_preset, int type, SoundControl *&ctrl, bool dopplerEffect)
 Initialize this Handle.
bool Is3D ()
 Detects if the source of this handle is 3D.
bool IsDopplerEffectEnabled ()
 Check if the doppler effect is enabled for this sound.
bool IsWithinMaximumDistance (csVector3 listenerPos) const
 Check if the listener is within the maximum distance allowed.
virtual void OnSoundChange (SoundControl *sndCtrl)
 This function is called everytime the volume or the toggle change.
virtual bool Perform (iTimerEvent *)
 Unpause the sound after the given delay has elapsed.
void RemoveCallback ()
 Remove the callback.
void RemoveCallback ()
 Remove the callback.
void SetAutoRemove (bool toggle)
 Whether to remove this Sound/Handle on pause.
void SetAutoRemove (bool toggle)
 Whether to remove this Sound/Handle on pause.
void SetCallback (void(*object), void(*function)(void *))
 Sets a Callback to a object function.
void SetCallback (void(*object), void(*function)(void *))
 Sets a Callback to a object function.
void SetID (uint identifier)
 Sets the ID of this handle.
 SoundHandle (SoundSystemManager *)
 constructor
 SoundHandle ()
 constructor
void UnpauseAfterDelay (unsigned int delay)
 Unpause the sound stream of this header after the given delay.
virtual ~SoundHandle ()
 destructor
 ~SoundHandle ()
 destructor

Public Attributes

bool autoremove
 remove this handle when pause?
int fade
 >0 is number of steps up <0 is number of steps down, 0 is nothing
bool fade_stop
 pause this sound after fading down true / false
float fade_volume
 volume we add or remove in each step (during fading)
csString name
 name of the resource or the file - not unique
float preset_volume
 the volume all calculations are based upon
SoundControlsndCtrl
csRef< iSndSysData > snddata
 pointer to sound data
csRef< iSndSysSource > sndsource
 sndsource if 2D
csRef< iSndSysSource3D > sndsource3d
 sndsource if 3D
csRef
< iSndSysSource3DDirectionalSimple > 
sndsourcedir
 additional source if 3D and directional
csRef< iSndSysStream > sndstream
 sound stream

Protected Attributes

float currentVolume
 the volume all calculations are based upon.
bool dopplerEffect
 true if the doppler effect is enabled for this sound

Detailed Description

Definition at line 40 of file handle.h.


Constructor & Destructor Documentation

SoundHandle::SoundHandle ( SoundSystemManager )

constructor

SoundHandle::~SoundHandle ( )

destructor

SoundHandle::SoundHandle ( )

constructor

virtual SoundHandle::~SoundHandle ( ) [virtual]

destructor


Member Function Documentation

void SoundHandle::ConvertTo3D ( float  mindist,
float  maxdist,
csVector3  pos,
csVector3  dir,
float  rad 
)

Converts this Handle to a 3D Handle.

Note: doesnt work when type is CS_SND3D_DISABLE Also created directional sources if rad > 0

Parameters:
mindistdistance when volume reaches max
maxdistdistance when volume is a min
pos3d position of this sound
dirdirection this sound is emitting to (if rad > 0)
radradiation of the directional cone
void SoundHandle::ConvertTo3D ( float  mindist,
float  maxdist,
csVector3  pos,
csVector3  dir,
float  rad 
)

Converts this Handle to a 3D Handle.

Note: doesnt work when type is CS_SND3D_DISABLE Also created directional sources if rad > 0

Parameters:
mindistdistance when volume reaches max
maxdistdistance when volume is a min
pos3d position of this sound
dirdirection this sound is emitting to (if rad > 0)
radradiation of the directional cone
void SoundHandle::Fade ( float  volume,
int  time,
int  direction 
)

Does fading calculation for this Handle.

Parameters:
volumevolume to add / substract
timetime within this must be done
directionFADE_DOWN / FADE_UP or FADE_STOP
void SoundHandle::Fade ( float  volume,
int  time,
int  direction 
)

Does fading calculation for this Handle.

Parameters:
volumevolume to add / substract
timetime within this must be done
directionFADE_DOWN / FADE_UP or FADE_STOP
void SoundHandle::FadeStep ( )

Perform a fading step if it is needed.

bool SoundHandle::GetAutoRemove ( )

Returns state of AutoRemove.

bool SoundHandle::GetAutoRemove ( )

Returns state of AutoRemove.

uint SoundHandle::GetID ( ) const [inline]

Gets the ID of this handle.

Returns:
the ID of this handle.

Definition at line 135 of file handle.h.

csVector3 SoundHandle::GetSourcePosition ( )

Gets the position of the source.

Note:
: always call SoundHandle::Is3D() before calling this method.
Returns:
the position of the source.
virtual bool SoundHandle::Init ( const char *  resname,
bool  loop,
float  volume_preset,
int  type,
SoundControl *&  ctrl,
bool  dopplerEffect 
) [virtual]

Initialize this Handle.

Done within this because its not failsave. Returns true or false.

Parameters:
resnamename of the resource
loopLOOP or DONT_LOOP
volume_presetvolume which all calculation are based upon
type3d type: can be CS_SND3D_DISABLE=0. CS_SND3D_RELATIVE=1 or CS_SND3D_ABSOLUTE=2
ctrlSoundControl which controls this Handle
dopplerEffecttrue to apply the doppler effect to this sound, false otherwise.

Reimplemented in SongHandle.

bool SoundHandle::Init ( const char *  resname,
bool  loop,
float  volume_preset,
int  type,
SoundControl *&  ctrl 
)

Initialize this Handle.

Done within this because its not failsave. Returns true or false.

Parameters:
resnamename of the resource
loopLOOP or DONT_LOOP
volume_presetvolume which all calculation are based upon
type3d type: can be CS_SND3D_DISABLE=0. CS_SND3D_RELATIVE=1 or CS_SND3D_ABSOLUTE=2
ctrlSoundControl which controls this Handle
bool SoundHandle::Is3D ( )

Detects if the source of this handle is 3D.

Returns:
true if the source is 3D, false otherwise.
bool SoundHandle::IsDopplerEffectEnabled ( )

Check if the doppler effect is enabled for this sound.

Returns:
true if the doppler effect is enabled, false otherwise.
bool SoundHandle::IsWithinMaximumDistance ( csVector3  listenerPos) const

Check if the listener is within the maximum distance allowed.

Parameters:
listenerPosthe listener position.
Returns:
true if the listener is within the maximum distance from the object.
virtual void SoundHandle::OnSoundChange ( SoundControl sndCtrl) [virtual]

This function is called everytime the volume or the toggle change.

Parameters:
sndCtrlthe SoundControl that has been changed.

Implements iSoundControlListener.

virtual bool SoundHandle::Perform ( iTimerEvent *  ) [virtual]

Unpause the sound after the given delay has elapsed.

void SoundHandle::RemoveCallback ( )

Remove the callback.

void SoundHandle::RemoveCallback ( )

Remove the callback.

void SoundHandle::SetAutoRemove ( bool  toggle)

Whether to remove this Sound/Handle on pause.

True means it will be removed when Sound is paused (Unamanged Sound). False means it will stay and leak if you dont take care (Managed Sound).

Parameters:
toggletrue or false
void SoundHandle::SetAutoRemove ( bool  toggle)

Whether to remove this Sound/Handle on pause.

True means it will be removed when Sound is paused (Unamanged Sound). False means it will stay and leak if you dont take care (Managed Sound).

Parameters:
toggletrue or false
void SoundHandle::SetCallback ( void *  object,
void(*)(void *)  function 
)

Sets a Callback to a object function.

Parameters:
objectpointer to the object
functionpointer to a static void function within the object
void SoundHandle::SetCallback ( void *  object,
void(*)(void *)  function 
)

Sets a Callback to a object function.

Parameters:
objectpointer to the object
functionpointer to a static void function within the object
void SoundHandle::SetID ( uint  identifier) [inline]

Sets the ID of this handle.

Parameters:
idthe new ID of this handle.

Definition at line 141 of file handle.h.

void SoundHandle::UnpauseAfterDelay ( unsigned int  delay)

Unpause the sound stream of this header after the given delay.

Parameters:
delaythe delay in milliseconds.

Member Data Documentation

remove this handle when pause?

Definition at line 49 of file handle.h.

the volume all calculations are based upon.

Definition at line 187 of file handle.h.

bool SoundHandle::dopplerEffect [protected]

true if the doppler effect is enabled for this sound

Definition at line 186 of file handle.h.

>0 is number of steps up <0 is number of steps down, 0 is nothing

Definition at line 46 of file handle.h.

pause this sound after fading down true / false

Definition at line 48 of file handle.h.

volume we add or remove in each step (during fading)

Definition at line 47 of file handle.h.

name of the resource or the file - not unique

Definition at line 43 of file handle.h.

the volume all calculations are based upon

Definition at line 45 of file handle.h.

See also:
SoundControl

Definition at line 44 of file handle.h.

csRef< iSndSysData > SoundHandle::snddata

pointer to sound data

Definition at line 51 of file handle.h.

csRef< iSndSysSource > SoundHandle::sndsource

sndsource if 2D

Definition at line 53 of file handle.h.

csRef< iSndSysSource3D > SoundHandle::sndsource3d

sndsource if 3D

Definition at line 54 of file handle.h.

csRef< iSndSysSource3DDirectionalSimple > SoundHandle::sndsourcedir

additional source if 3D and directional

Definition at line 55 of file handle.h.

csRef< iSndSysStream > SoundHandle::sndstream

sound stream

Definition at line 52 of file handle.h.


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