NL3D::CPSSoundInstanceImpl Class Reference

#include <u_ps_sound_impl.h>

Inheritance diagram for NL3D::CPSSoundInstanceImpl:

NL3D::UPSSoundInstance

Detailed Description

This class implement a sound instance (a sound source).

Definition at line 53 of file u_ps_sound_impl.h.

Public Member Functions

 CPSSoundInstanceImpl ()
 construct this object from a nel sound source

virtual float getPitch () const
 get pitch

void init (NLSOUND::USource *source, CPSSoundServImpl *soundServImp, bool spawned)
 init this sound instance parameters

virtual bool isPlaying (void) const
 tells wether the sound is playing

virtual void play (void)
 start to play the sound

virtual void release (void)
 release the sound source

virtual void setLooping (bool looping)
virtual void setSoundParams (float gain, const NLMISC::CVector &pos, const NLMISC::CVector &velocity, float pitch)
 change this sound source paramerters

virtual void stop (void)
 stop the sound


Protected Attributes

CPSSoundServImpl_SoundServImpl
NLSOUND::USource_Source
bool _Spawned

Friends

void SpawnedSourceEndedCallback (NLSOUND::USource *source, void *userParam)
 this callback is called when a spawned source has ended, so that we know that the pointer to it is invalid...


Constructor & Destructor Documentation

NL3D::CPSSoundInstanceImpl::CPSSoundInstanceImpl  )  [inline]
 

construct this object from a nel sound source

The system will call this method to set the parameters of the sound

Definition at line 59 of file u_ps_sound_impl.h.

References _SoundServImpl, _Spawned, and NL3D_MEM_PS_SOUND.

00060                 : _Source(NULL), _SoundServImpl(NULL), _Spawned(false)
00061         {
00062                 NL3D_MEM_PS_SOUND
00063         }


Member Function Documentation

virtual float NL3D::CPSSoundInstanceImpl::getPitch  )  const [inline, virtual]
 

get pitch

Implements NL3D::UPSSoundInstance.

Definition at line 118 of file u_ps_sound_impl.h.

References NLSOUND::USource::getPitch(), and NL3D_MEM_PS_SOUND.

00119         {
00120                 NL3D_MEM_PS_SOUND
00121                 if (!_Source) return 0.f;
00122                 return _Source->getPitch();
00123         }

void NL3D::CPSSoundInstanceImpl::init NLSOUND::USource source,
CPSSoundServImpl soundServImp,
bool  spawned
[inline]
 

init this sound instance parameters

Definition at line 66 of file u_ps_sound_impl.h.

References _SoundServImpl, _Spawned, NL3D_MEM_PS_SOUND, and nlassert.

Referenced by NL3D::CPSSoundServImpl::createSound().

00067         {
00068                 NL3D_MEM_PS_SOUND
00069                 nlassert(source);
00070                 _Source = source;               
00071                 _Spawned    = spawned;
00072                 _SoundServImpl = soundServImp;
00073         }

virtual bool NL3D::CPSSoundInstanceImpl::isPlaying void   )  const [inline, virtual]
 

tells wether the sound is playing

Implements NL3D::UPSSoundInstance.

Definition at line 102 of file u_ps_sound_impl.h.

References NLSOUND::USource::isPlaying(), and NL3D_MEM_PS_SOUND.

00103         {
00104                 NL3D_MEM_PS_SOUND
00105                 if (!_Source) return false;
00106                 return _Source->isPlaying();
00107         }

virtual void NL3D::CPSSoundInstanceImpl::play void   )  [inline, virtual]
 

start to play the sound

Implements NL3D::UPSSoundInstance.

Definition at line 94 of file u_ps_sound_impl.h.

References NL3D_MEM_PS_SOUND, and NLSOUND::USource::play().

00095         {
00096                 NL3D_MEM_PS_SOUND
00097                 if (!_Source) return;
00098                 _Source->play();
00099         }

void NL3D::CPSSoundInstanceImpl::release void   )  [virtual]
 

release the sound source

Implements NL3D::UPSSoundInstance.

Definition at line 217 of file u_ps_sound_impl.h.

References _SoundServImpl, _Spawned, NL3D::CPSSoundServImpl::getAudioMixer(), and NLSOUND::USource::unregisterSpawnCallBack().

00218 {       
00219         if (!_Spawned) // remove this source from the audio mixer if it hasn't been spawned
00220         {
00221                 if (_SoundServImpl->getAudioMixer())
00222                 {                       
00223 //                      _SoundServImpl->getAudioMixer()->removeSource(_Source);
00224                         delete _Source;
00225                 }
00226         }
00227         else
00228         {
00229                 if (_Source) // tells this spawned source not to notify us when it ends
00230                 {
00231                         _Source->unregisterSpawnCallBack();
00232                 }
00233         }
00234         delete this;
00235 }

virtual void NL3D::CPSSoundInstanceImpl::setLooping bool  looping  )  [inline, virtual]
 

Implements NL3D::UPSSoundInstance.

Definition at line 126 of file u_ps_sound_impl.h.

References NL3D_MEM_PS_SOUND, and NLSOUND::USource::setLooping().

00127         {
00128                 NL3D_MEM_PS_SOUND
00129                 if (_Source) _Source->setLooping(looping);
00130         }

virtual void NL3D::CPSSoundInstanceImpl::setSoundParams float  gain,
const NLMISC::CVector pos,
const NLMISC::CVector velocity,
float  pitch
[inline, virtual]
 

change this sound source paramerters

Implements NL3D::UPSSoundInstance.

Definition at line 76 of file u_ps_sound_impl.h.

References NL3D_MEM_PS_SOUND, NLSOUND::USource::setPitch(), NLSOUND::USource::setPos(), NLSOUND::USource::setRelativeGain(), and NLSOUND::USource::setVelocity().

00081         {
00082                 NL3D_MEM_PS_SOUND
00083                 if (!_Source) return;           
00084                 if (gain < 0) gain = 0;
00085                 if (gain > 1) gain = 1;         
00086                 if (pitch < 0.0001f) pitch = 0.0001f;
00087                 _Source->setPos(pos);
00088                 _Source->setVelocity(velocity);
00089                 _Source->setRelativeGain(gain);
00090                 _Source->setPitch(pitch);
00091         }

virtual void NL3D::CPSSoundInstanceImpl::stop void   )  [inline, virtual]
 

stop the sound

Implements NL3D::UPSSoundInstance.

Definition at line 110 of file u_ps_sound_impl.h.

References NL3D_MEM_PS_SOUND, and NLSOUND::USource::stop().

00111         {
00112                 NL3D_MEM_PS_SOUND
00113                 if (!_Source) return;
00114                 _Source->stop();
00115         }


Friends And Related Function Documentation

void SpawnedSourceEndedCallback NLSOUND::USource source,
void *  userParam
[friend]
 

this callback is called when a spawned source has ended, so that we know that the pointer to it is invalid...


Field Documentation

CPSSoundServImpl* NL3D::CPSSoundInstanceImpl::_SoundServImpl [protected]
 

Definition at line 140 of file u_ps_sound_impl.h.

Referenced by CPSSoundInstanceImpl(), init(), and release().

NLSOUND::USource* NL3D::CPSSoundInstanceImpl::_Source [protected]
 

Definition at line 138 of file u_ps_sound_impl.h.

bool NL3D::CPSSoundInstanceImpl::_Spawned [protected]
 

Definition at line 139 of file u_ps_sound_impl.h.

Referenced by CPSSoundInstanceImpl(), init(), and release().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 07:25:51 2004 for NeL by doxygen 1.3.6