NLSOUND::CSimpleSource Class Reference

#include <simple_source.h>

Inheritance diagram for NLSOUND::CSimpleSource:

NLSOUND::CSourceCommon NLSOUND::CAudioMixerUser::IMixerEvent NLSOUND::USource NLMISC::CDbgRefCount< IMixerEvent >

Detailed Description

Implementation of USource
Author:
Olivier Cado

Nevrax France

Date:
2001

Definition at line 52 of file simple_source.h.

Source properties

virtual IBuffergetBuffer ()
TSpawnEndCallback getSpawnEndCallback () const
 Return the spawn end callback.

CTrackgetTrack ()
 Return the track.

NLMISC::CVector getVirtualPos () const
virtual void setDirection (const NLMISC::CVector &dir)
 Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional).

virtual void setGain (float gain)
virtual void setPitch (float pitch)
virtual void setPos (const NLMISC::CVector &pos)
virtual void setRelativeGain (float gain)
virtual void setSourceRelativeMode (bool mode)
 Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false).

virtual void setVelocity (const NLMISC::CVector &vel)
 Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)).

TSOURCE_TYPE getType () const
 Get the type the the source.

virtual void onEvent ()
float _Alpha
bool _PlayMuted
CSimpleSound_Sound
CTrack_Track

Public Types

enum  TSOURCE_TYPE { SOURCE_SIMPLE, SOURCE_COMPLEX, SOURCE_BACKGROUND }

Public Member Functions

virtual void checkup ()
 CSimpleSource (CSimpleSound *simpleSound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam=0, NL3D::CCluster *cluster=0)
 Constructor.

void * getCallbackUserParam (void) const
 return the user param for the user callback

NL3D::CClustergetCluster () const
virtual void getDirection (NLMISC::CVector &dir) const
 Get the direction vector.

virtual float getGain () const
 Get the gain.

bool getLooping () const
 Return the looping state.

virtual float getPitch () const
 Get the pitch.

const NLMISC::CVectorgetPos () const
 Get the position vector (3D mode only).

TSoundPriority getPriority () const
 Return the priority.

float getRelativeGain () const
 Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.

CSimpleSoundgetSimpleSound ()
 Return the simple sound bound to the source (or NULL).

virtual TSoundId getSound ()
 Return the sound binded to the source (or NULL if there is no sound).

virtual bool getSourceRelativeMode () const
 Get the source relative mode.

virtual void getVelocity (NLMISC::CVector &vel) const
 Get the velocity vector.

bool isSpawn () const
 Return the spawn state.

void set3DPositionVector (const NLMISC::CVector *pos)
 Set the position vector to return for a stereo source (default: NULL).

void setPriority (TSoundPriority pr)
 Change the priority of the source.

virtual void unregisterSpawnCallBack ()
 Tells this source not to call its callbacks when it ends. This is valid for spawned sources only.

virtual ~CSimpleSource ()
 Destructor.

Playback control
virtual NLMISC::TTicks getPlayTime ()
virtual uint32 getTime ()
 Returns the number of milliseconds the source has been playing.

virtual bool isPlaying ()
 Get playing state. Return false even if the source has stopped on its own.

virtual void play ()
 Play.

virtual void setLooping (bool l)
 Set looping on/off for future playbacks (default: off).

virtual void stop ()
 Stop playing.


Protected Attributes

const NLMISC::CVector_3DPosition
void * _CbUserParam
NL3D::CCluster_Cluster
NLMISC::CVector _Direction
float _Gain
float _InitialGain
 Gain not affected by setRelativeGain and used to compute _Gain.

bool _Looping
float _Pitch
bool _Playing
NLMISC::TTime _PlayStart
NLMISC::CVector _Position
TSoundPriority _Priority
bool _RelativeMode
const bool _Spawn
TSpawnEndCallback _SpawnEndCb
NLMISC::TStringId _UserVarControler
 An optional user var controler.

NLMISC::CVector _Velocity


Member Enumeration Documentation

enum NLSOUND::CSourceCommon::TSOURCE_TYPE [inherited]
 

Enumeration values:
SOURCE_SIMPLE 
SOURCE_COMPLEX 
SOURCE_BACKGROUND 

Definition at line 42 of file source_common.h.

00043         {
00044                 SOURCE_SIMPLE,
00045                 SOURCE_COMPLEX,
00046                 SOURCE_BACKGROUND
00047         };


Constructor & Destructor Documentation

NLSOUND::CSimpleSource::CSimpleSource CSimpleSound simpleSound = NULL,
bool  spawn = false,
TSpawnEndCallback  cb = 0,
void *  cbUserParam = 0,
NL3D::CCluster cluster = 0
 

Constructor.

Definition at line 45 of file simple_source.cpp.

References _Sound, NLSOUND::CSimpleSound::getAlpha(), nlassert, and NLSOUND::TSpawnEndCallback.

00046 :       CSourceCommon(simpleSound, spawn, cb, cbUserParam, cluster),
00047         _Track(NULL), _PlayMuted(false)
00048 {
00049         nlassert(simpleSound != 0);
00050         _Sound = simpleSound;
00051 
00052         // get a local copy of the simple sound parameter
00053         _Alpha = _Sound->getAlpha();
00054 }

NLSOUND::CSimpleSource::~CSimpleSource  )  [virtual]
 

Destructor.

Definition at line 60 of file simple_source.cpp.

References stop().

00061 {
00062         if (_Playing)
00063                 stop();
00064 }


Member Function Documentation

virtual void NLSOUND::CSourceCommon::checkup  )  [inline, virtual, inherited]
 

This method is called from backgroup sound to check if subsound need to be restarted (ie subsound in loop mode).

Reimplemented in NLSOUND::CComplexSource.

Definition at line 103 of file source_common.h.

Referenced by NLSOUND::CBackgroundSoundManager::updateBackgroundStatus().

00103 {};

IBuffer * NLSOUND::CSimpleSource::getBuffer  )  [virtual]
 

Definition at line 82 of file simple_source.cpp.

References _Sound, and NLSOUND::CSimpleSound::getBuffer().

Referenced by NLSOUND::CAudioMixerUser::bufferUnloaded(), and NLSOUND::CAudioMixerUser::createSource().

00083 {
00084         return _Sound->getBuffer();
00085 }

void* NLSOUND::CSourceCommon::getCallbackUserParam void   )  const [inline, inherited]
 

return the user param for the user callback

Definition at line 74 of file source_common.h.

References NLSOUND::CSourceCommon::_CbUserParam.

00074 { return _CbUserParam; }

NL3D::CCluster* NLSOUND::CSourceCommon::getCluster  )  const [inline, inherited]
 

Definition at line 98 of file source_common.h.

References NLSOUND::CSourceCommon::_Cluster.

Referenced by getVirtualPos(), and NLSOUND::CAudioMixerUser::update().

00098 { return _Cluster; } 

virtual void NLSOUND::CSourceCommon::getDirection NLMISC::CVector dir  )  const [inline, virtual, inherited]
 

Get the direction vector.

Implements NLSOUND::USource.

Definition at line 80 of file source_common.h.

00080 { dir = _Direction; }

virtual float NLSOUND::CSourceCommon::getGain void   )  const [inline, virtual, inherited]
 

Get the gain.

Implements NLSOUND::USource.

Definition at line 82 of file source_common.h.

Referenced by NLSOUND::CAudioMixerUser::update().

00082 { return _Gain; }

bool NLSOUND::CSourceCommon::getLooping  )  const [virtual, inherited]
 

Return the looping state.

Implements NLSOUND::USource.

Definition at line 99 of file source_common.cpp.

00100 {
00101         return _Looping;
00102 }

virtual float NLSOUND::CSourceCommon::getPitch void   )  const [inline, virtual, inherited]
 

Get the pitch.

Implements NLSOUND::USource.

Definition at line 84 of file source_common.h.

00084 { return _Pitch; }

virtual NLMISC::TTicks NLSOUND::CSimpleSource::getPlayTime  )  [inline, virtual]
 

Definition at line 84 of file simple_source.h.

References getTime(), and NLMISC::TTicks.

00084 { return getTime(); }

const NLMISC::CVector & NLSOUND::CSourceCommon::getPos  )  const [virtual, inherited]
 

Get the position vector (3D mode only).

Implements NLSOUND::USource.

Definition at line 141 of file source_common.cpp.

References NLSOUND::CSourceCommon::_3DPosition.

Referenced by NLSOUND::CAudioMixerUser::getFreeTrack(), NLSOUND::CAudioMixerUser::getPlayingSoundsPos(), getVirtualPos(), NLSOUND::CompareSources::operator()(), and NLSOUND::CAudioMixerUser::update().

00142 {
00143         if ( _3DPosition == NULL )
00144         {
00145                 return _Position;
00146         }
00147         else
00148         {
00149                 return *_3DPosition;
00150         }
00151         
00152 }

TSoundPriority NLSOUND::CSourceCommon::getPriority void   )  const [inline, inherited]
 

Return the priority.

Definition at line 59 of file source_common.h.

References NLSOUND::TSoundPriority.

Referenced by NLSOUND::CAudioMixerUser::freeTrack(), NLSOUND::CAudioMixerUser::getFreeTrack(), and NLSOUND::CompareSources::operator()().

00059 { return _Priority; }

float NLSOUND::CSourceCommon::getRelativeGain  )  const [virtual, inherited]
 

Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.

Implements NLSOUND::USource.

Definition at line 205 of file source_common.cpp.

References NLSOUND::CSourceCommon::_InitialGain.

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource(), and NLSOUND::CAudioMixerUser::update().

00206 {
00207         if (_InitialGain == 0.0f)
00208                 return 0.0f;
00209         else
00210                 return _Gain / _InitialGain;
00211 }

CSimpleSound * NLSOUND::CSimpleSource::getSimpleSound  ) 
 

Return the simple sound bound to the source (or NULL).

Definition at line 66 of file simple_source.cpp.

References _Sound.

Referenced by NLSOUND::CAudioMixerUser::getFreeTrack().

00067 {
00068         return _Sound;
00069 }

virtual TSoundId NLSOUND::CSimpleSource::getSound  )  [inline, virtual]
 

Return the sound binded to the source (or NULL if there is no sound).

Implements NLSOUND::USource.

Definition at line 69 of file simple_source.h.

References _Sound, and NLSOUND::TSoundId.

Referenced by NLSOUND::CAmbiantSource::enable(), and NLSOUND::CAmbiantSource::update().

00069 { return _Sound; }

virtual bool NLSOUND::CSourceCommon::getSourceRelativeMode  )  const [inline, virtual, inherited]
 

Get the source relative mode.

Implements NLSOUND::USource.

Definition at line 86 of file source_common.h.

References NLSOUND::CSourceCommon::_RelativeMode.

00086 { return _RelativeMode; }

TSpawnEndCallback NLSOUND::CSimpleSource::getSpawnEndCallback  )  const [inline]
 

Return the spawn end callback.

Definition at line 131 of file simple_source.h.

References NLSOUND::TSpawnEndCallback.

00131 { return _SpawnEndCb; }

uint32 NLSOUND::CSimpleSource::getTime  )  [virtual]
 

Returns the number of milliseconds the source has been playing.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 71 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, NLSOUND::ISource::getTime(), and uint32.

Referenced by getPlayTime().

00072 {
00073         if (_Track && _Track->DrvSource)
00074         {
00075                 return _Track->DrvSource->getTime();
00076         }
00077         else
00078                 return 0;
00079 }

CTrack* NLSOUND::CSimpleSource::getTrack  )  [inline]
 

Return the track.

Definition at line 129 of file simple_source.h.

References _Track.

Referenced by NLSOUND::CAudioMixerUser::getPlayingSoundsPos(), and NLSOUND::CAmbiantSource::update().

00129 { return _Track; }

TSOURCE_TYPE NLSOUND::CSimpleSource::getType  )  const [inline, private, virtual]
 

Get the type the the source.

Implements NLSOUND::CSourceCommon.

Definition at line 141 of file simple_source.h.

00141 {return SOURCE_SIMPLE;}

virtual void NLSOUND::CSourceCommon::getVelocity NLMISC::CVector vel  )  const [inline, virtual, inherited]
 

Get the velocity vector.

Implements NLSOUND::USource.

Definition at line 78 of file source_common.h.

References NLSOUND::CSourceCommon::_Velocity.

00078 { vel = _Velocity; }

CVector NLSOUND::CSimpleSource::getVirtualPos  )  const
 

Get the virtual source position. This method compute the virtual source position with cluster system.

Definition at line 103 of file simple_source.cpp.

References NLSOUND::CClusteredSound::CClusterSoundStatus::Direction, NLSOUND::CClusteredSound::CClusterSoundStatus::Dist, NLSOUND::CSourceCommon::getCluster(), NLSOUND::CSourceCommon::getPos(), NLSOUND::CClusteredSound::CClusterSoundStatus::PosAlpha, and NLSOUND::CClusteredSound::CClusterSoundStatus::Position.

Referenced by NLSOUND::CAudioMixerUser::getPlayingSoundsPos(), play(), and setPos().

00104 {
00105         if (getCluster() != 0)
00106         {
00107                 // need to check the cluster status
00108                 const CClusteredSound::CClusterSoundStatus *css = CAudioMixerUser::instance()->getClusteredSound()->getClusterSoundStatus(getCluster());
00109                 if (css != 0)
00110                 {
00111                         // there is some data here, update the virtual position of the sound.
00112                         float dist = (css->Position - getPos()).norm();
00113                         CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + css->Direction * (css->Dist + dist));
00114                         vpos = _Position * (1-css->PosAlpha) + vpos*(css->PosAlpha);
00115                         return vpos;
00116                 }
00117         }
00118 
00119         return _Position;
00120 }

bool NLSOUND::CSimpleSource::isPlaying  )  [virtual]
 

Get playing state. Return false even if the source has stopped on its own.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 381 of file simple_source.cpp.

Referenced by NLSOUND::CAudioMixerUser::getPlayingSoundsPos().

00382 {
00383         return _Playing;
00384 }

bool NLSOUND::CSourceCommon::isSpawn  )  const [inline, inherited]
 

Return the spawn state.

Definition at line 90 of file source_common.h.

00090 { return _Spawn; }

void NLSOUND::CSimpleSource::onEvent  )  [private, virtual]
 

Implements NLSOUND::CAudioMixerUser::IMixerEvent.

Definition at line 200 of file simple_source.cpp.

References _PlayMuted, and stop().

00201 {
00202 //      nldebug("CSimpleSource %p : stop EVENT", (CAudioMixerUser::IMixerEvent*)this);
00203         // A muted play is terminated.
00204         if (!_Playing)
00205                 return;
00206 //      nlassert(_Playing);
00207 //      nlassert(_Track == 0);
00208         _PlayMuted = false;
00209         CAudioMixerUser::instance()->decPlayingSourceMuted();
00210 
00211         stop();
00212 }

void NLSOUND::CSimpleSource::play  )  [virtual]
 

Play.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 126 of file simple_source.cpp.

References _PlayMuted, _Sound, NLSOUND::CSourceCommon::_SpawnEndCb, _Track, NLSOUND::CAudioMixerUser::addEvent(), NLSOUND::CAudioMixerUser::addSourceWaitingForPlay(), NLSOUND::CTrack::DrvSource, NLSOUND::CSimpleSound::getBuffer(), NLSOUND::CSimpleSound::getDuration(), NLSOUND::CAudioMixerUser::getFreeTrack(), NLSOUND::CAudioMixerUser::getListenPosVector(), NLSOUND::CSound::getMaxDistance(), NLSOUND::CSimpleSound::getMinDistance(), getVirtualPos(), NLSOUND::HighestPri, NLSOUND::CAudioMixerUser::incPlayingSourceMuted(), NLSOUND::IBuffer::isBufferLoaded(), NLSOUND::IBuffer::isStereo(), nlassert, NLSOUND::ISource::play(), NLSOUND::ISource::setAlpha(), setDirection(), NLSOUND::ISource::setGain(), NLSOUND::ISource::setLooping(), NLSOUND::ISource::setMinMaxDistances(), NLSOUND::ISource::setPitch(), NLSOUND::ISource::setPos(), NLSOUND::ISource::setSourceRelativeMode(), NLSOUND::ISource::setStaticBuffer(), and NLSOUND::ISource::setVelocity().

Referenced by NLSOUND::CAmbiantSource::enable(), and NLSOUND::CAmbiantSource::update().

00127 {
00128 //      nldebug("CSimpleSource %p : play", this);
00129 
00130         CAudioMixerUser *mixer = CAudioMixerUser::instance();
00131 
00132         // -- Some test to scheck if we can play the source
00133         
00134         // Check if sample buffer is available and if the sound source is not too far
00135         if (_Sound->getBuffer() == 0 
00136                 || !_Sound->getBuffer()->isBufferLoaded()
00137                 || (mixer->getListenPosVector() - _Position).sqrnorm() > _Sound->getMaxDistance()*_Sound->getMaxDistance())
00138         {
00139                 // The sample buffer is not available, don't play (we don't know the lenght)
00140                 if (_Spawn)
00141                 {
00142                         if (_SpawnEndCb != 0)
00143                                 _SpawnEndCb(this, _CbUserParam);
00144 
00145                         delete this;
00146                 }
00147 //              nldebug("CSimpleSource %p : play FAILED !", (CAudioMixerUser::IMixerEvent*)this);
00148                 return;
00149         }
00150 
00151         // -- Here we can play the source, either in a real track or as a muted source.
00152 
00153         // Try to obtain a track
00154         if (_Track == 0)
00155                 _Track = mixer->getFreeTrack(this);
00156         if (_Track != 0)
00157         {
00158                 // ok, we have a track to realy play, fill the data into the track
00159                 _Track->DrvSource->setStaticBuffer(_Sound->getBuffer());
00160 
00161 //              _Track->DrvSource->setPos( _Position, false);
00162                 _Track->DrvSource->setPos( getVirtualPos(), false);
00163                 if ( ! _Sound->getBuffer()->isStereo() )
00164                 {
00165                         _Track->DrvSource->setMinMaxDistances( _Sound->getMinDistance(), _Sound->getMaxDistance(), false );
00166                         setDirection( _Direction ); // because there is a workaround inside
00167                         _Track->DrvSource->setVelocity( _Velocity );
00168                 }
00169                 _Track->DrvSource->setGain( _Gain );
00170                 _Track->DrvSource->setSourceRelativeMode( _RelativeMode );
00171                 _Track->DrvSource->setLooping( _Looping );
00172                 _Track->DrvSource->setPitch( _Pitch );
00173                 _Track->DrvSource->setAlpha( _Alpha );
00174                 
00175                 // and play the sound           
00176                 bool play = _Track->DrvSource->play();
00177 
00178                 nlassert(play);
00179 //              nldebug("CSimpleSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this);
00180         }
00181         else
00182         {
00183                 if (_Priority == HighestPri)
00184                 {
00185                         // This sound is not discardable, add it in waiting playlist
00186                         mixer->addSourceWaitingForPlay(this);
00187                         return;
00188                 }
00189                 // there is no available track, just do a 'muted' play
00190                 mixer->addEvent(this, CTime::getLocalTime()+_Sound->getDuration());
00191                 _PlayMuted = true;
00192                 mixer->incPlayingSourceMuted();
00193 //              nldebug("CSimpleSource %p : MUTED play done", (CAudioMixerUser::IMixerEvent*)this);
00194         }
00195 
00196         CSourceCommon::play();
00197 
00198 }

void NLSOUND::CSourceCommon::set3DPositionVector const NLMISC::CVector pos  )  [inline, inherited]
 

Set the position vector to return for a stereo source (default: NULL).

Definition at line 88 of file source_common.h.

References NLSOUND::CSourceCommon::_3DPosition.

Referenced by NLSOUND::CAudioMixerUser::createSource(), and NLSOUND::CAmbiantSource::initPos().

00088 { _3DPosition = pos; }

void NLSOUND::CSimpleSource::setDirection const NLMISC::CVector dir  )  [virtual]
 

Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional).

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 290 of file simple_source.cpp.

References _Sound, _Track, NLSOUND::CTrack::DrvSource, NLSOUND::CSimpleSound::getBuffer(), NLSOUND::CSound::getConeInnerAngle(), NLSOUND::CSound::getConeOuterAngle(), NLSOUND::CSound::getConeOuterGain(), NLMISC::CVector::isNull(), NLSOUND::IBuffer::isStereo(), NLMISC::Pi, NLSOUND::ISource::setCone(), and NLSOUND::ISource::setDirection().

Referenced by play().

00291 {
00292         CSourceCommon::setDirection(dir);
00293 
00294         // Set the direction
00295         if ( _Track != NULL )
00296         {
00297                 if ( ! _Sound->getBuffer()->isStereo() )
00298                 {
00299                         static bool coneset = false;
00300                         if ( dir.isNull() ) // workaround
00301                         {
00302                                 _Track->DrvSource->setCone( float(Pi*2), float(Pi*2), 1.0f ); // because the direction with 0 is not enough for a non-directional source!
00303                                 _Track->DrvSource->setDirection( CVector::I );  // Don't send a 0 vector, DSound will complain. Send (1,0,0), it's omnidirectional anyway.
00304                                 coneset = false;
00305                         }
00306                         else
00307                         {
00308 //                              if ( ! coneset )
00309                                 {
00310                                         _Track->DrvSource->setCone( _Sound->getConeInnerAngle(), _Sound->getConeOuterAngle(), _Sound->getConeOuterGain() );
00311                                         coneset = true;
00312                                 }
00313                                 _Track->DrvSource->setDirection( dir );
00314                         }
00315                 }
00316         }
00317 }

void NLSOUND::CSimpleSource::setGain float  gain  )  [virtual]
 

Set the gain (volume value inside [0 , 1]). (default: 1) 0.0 -> silence 0.5 -> -6dB 1.0 -> no attenuation values > 1 (amplification) not supported by most drivers

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 326 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setGain().

Referenced by NLSOUND::CAmbiantSource::initPos(), and NLSOUND::CAudioMixerUser::update().

00327 {
00328         CSourceCommon::setGain(gain);
00329 
00330         // Set the gain
00331         if ( _Track != NULL )
00332         {
00333                 _Track->DrvSource->setGain( gain );
00334         }
00335 }

void NLSOUND::CSimpleSource::setLooping bool  l  )  [virtual]
 

Set looping on/off for future playbacks (default: off).

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 93 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setLooping().

Referenced by NLSOUND::CAmbiantSource::CAmbiantSource().

00094 {
00095         CSourceCommon::setLooping(l);
00096         if ( _Track != NULL )
00097         {
00098                 _Track->DrvSource->setLooping( l );
00099         }
00100 }

void NLSOUND::CSimpleSource::setPitch float  pitch  )  [virtual]
 

Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift of one octave. 0 is not a legal value.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 352 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setPitch().

00353 {
00354         CSourceCommon::setPitch(pitch);
00355 
00356         // Set the pitch
00357         if ( _Track != NULL )
00358         {
00359                 _Track->DrvSource->setPitch( pitch );
00360         }
00361 }

void NLSOUND::CSimpleSource::setPos const NLMISC::CVector pos  )  [virtual]
 

Set the position vector (default: (0,0,0)). 3D mode -> 3D position st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 258 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, getVirtualPos(), and NLSOUND::ISource::setPos().

Referenced by NLSOUND::CAudioMixerUser::update().

00259 {
00260         CSourceCommon::setPos(pos);
00261 
00262         // Set the position
00263         if ( _Track != NULL )
00264         {
00265 //              _Track->DrvSource->setPos( pos );
00266                 _Track->DrvSource->setPos( getVirtualPos() );
00267         }
00268 }

void NLSOUND::CSourceCommon::setPriority TSoundPriority  pr  )  [virtual, inherited]
 

Change the priority of the source.

Implements NLSOUND::USource.

Definition at line 76 of file source_common.cpp.

Referenced by NLSOUND::CAmbiantSource::enable(), NLSOUND::CAmbiantSource::initPos(), and NLSOUND::CAmbiantSource::update().

00077 {
00078         _Priority = pr;
00079 
00080         // The AudioMixer redispatches as necessary in the update() function [PH]
00081         // Redispatch the tracks if needed
00082         //if ( redispatch )
00083         //{
00084         //      CAudioMixerUser::instance()->balanceSources();
00085         //}
00086 }

void NLSOUND::CSimpleSource::setRelativeGain float  gain  )  [virtual]
 

Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain (which is getSource()->getGain()). Does nothing if getSource() is null.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 337 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setGain().

Referenced by NLSOUND::CAmbiantSource::update().

00338 {
00339         CSourceCommon::setRelativeGain(gain);
00340 
00341         // Set the gain
00342         if ( _Track != NULL )
00343         {
00344                 _Track->DrvSource->setGain( _Gain );
00345         }
00346 }

void NLSOUND::CSimpleSource::setSourceRelativeMode bool  mode  )  [virtual]
 

Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false).

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 367 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setSourceRelativeMode().

00368 {
00369         CSourceCommon::setSourceRelativeMode(mode);
00370 
00371         // Set the relative mode
00372         if ( _Track != NULL )
00373         {
00374                 _Track->DrvSource->setSourceRelativeMode( mode );
00375         }
00376 }

void NLSOUND::CSimpleSource::setVelocity const NLMISC::CVector vel  )  [virtual]
 

Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)).

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 274 of file simple_source.cpp.

References _Track, NLSOUND::CTrack::DrvSource, and NLSOUND::ISource::setVelocity().

00275 {
00276         CSourceCommon::setVelocity(vel);
00277 
00278         // Set the velocity
00279         if ( _Track != NULL )
00280         {
00281                 // TODO : uncoment, test only   
00282                 _Track->DrvSource->setVelocity( vel );
00283         }
00284 }

void NLSOUND::CSimpleSource::stop  )  [virtual]
 

Stop playing.

Reimplemented from NLSOUND::CSourceCommon.

Definition at line 217 of file simple_source.cpp.

References _PlayMuted, NLSOUND::CSourceCommon::_SpawnEndCb, _Track, NLSOUND::CTrack::DrvSource, NLSOUND::ISource::setStaticBuffer(), and NLSOUND::ISource::stop().

Referenced by NLSOUND::CAudioMixerUser::bufferUnloaded(), NLSOUND::CAmbiantSource::enable(), NLSOUND::CAudioMixerUser::getFreeTrack(), onEvent(), NLSOUND::CAudioMixerUser::update(), NLSOUND::CAmbiantSource::update(), and ~CSimpleSource().

00218 {
00219 //      nldebug("CSimpleSource %p : stop", (CAudioMixerUser::IMixerEvent*)this);
00220 //      nlassert(_Playing);
00221         if (!_Playing)
00222                 return;
00223 
00224         if (_Track != 0)
00225         {
00226                 // free the track
00227                 _Track->DrvSource->stop();
00228                 _Track->DrvSource->setStaticBuffer(0);
00229                 CAudioMixerUser::instance()->freeTrack(_Track);
00230                 _Track = 0;
00231         }
00232         else if (_PlayMuted)
00233         {
00234                 // clear the registered event because of a stop before normal end of play
00235                 CAudioMixerUser::instance()->decPlayingSourceMuted();
00236                 CAudioMixerUser::instance()->removeEvents(this);
00237         }
00238 
00239 //      CAudioMixerUser::instance()->decPlayingSource();
00240         CSourceCommon::stop();
00241 
00242         if (_Spawn)
00243         {
00244                 if ( _SpawnEndCb != 0 )
00245                 {
00246                         _SpawnEndCb( this, _CbUserParam);
00247                 }
00248 
00249                 delete this;
00250         }
00251 }

virtual void NLSOUND::CSourceCommon::unregisterSpawnCallBack  )  [inline, virtual, inherited]
 

Tells this source not to call its callbacks when it ends. This is valid for spawned sources only.

Implements NLSOUND::USource.

Definition at line 76 of file source_common.h.

References NLSOUND::CSourceCommon::_SpawnEndCb.

00076 { _SpawnEndCb = NULL; }


Field Documentation

const NLMISC::CVector* NLSOUND::CSourceCommon::_3DPosition [protected, inherited]
 

Definition at line 125 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getPos(), and NLSOUND::CSourceCommon::set3DPositionVector().

float NLSOUND::CSimpleSource::_Alpha [private]
 

Definition at line 147 of file simple_source.h.

void* NLSOUND::CSourceCommon::_CbUserParam [protected, inherited]
 

Definition at line 130 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getCallbackUserParam().

NL3D::CCluster* NLSOUND::CSourceCommon::_Cluster [protected, inherited]
 

Definition at line 131 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getCluster().

NLMISC::CVector NLSOUND::CSourceCommon::_Direction [protected, inherited]
 

Definition at line 113 of file source_common.h.

float NLSOUND::CSourceCommon::_Gain [protected, inherited]
 

Definition at line 114 of file source_common.h.

float NLSOUND::CSourceCommon::_InitialGain [protected, inherited]
 

Gain not affected by setRelativeGain and used to compute _Gain.

Definition at line 119 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::CSourceCommon(), NLSOUND::CSourceCommon::getRelativeGain(), NLSOUND::CSourceCommon::setGain(), and NLSOUND::CSourceCommon::setRelativeGain().

bool NLSOUND::CSourceCommon::_Looping [protected, inherited]
 

Definition at line 109 of file source_common.h.

float NLSOUND::CSourceCommon::_Pitch [protected, inherited]
 

Definition at line 115 of file source_common.h.

bool NLSOUND::CSourceCommon::_Playing [protected, inherited]
 

Definition at line 108 of file source_common.h.

bool NLSOUND::CSimpleSource::_PlayMuted [private]
 

Definition at line 152 of file simple_source.h.

Referenced by onEvent(), play(), and stop().

NLMISC::TTime NLSOUND::CSourceCommon::_PlayStart [protected, inherited]
 

Definition at line 122 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getTime(), and NLSOUND::CSourceCommon::play().

NLMISC::CVector NLSOUND::CSourceCommon::_Position [protected, inherited]
 

Definition at line 111 of file source_common.h.

TSoundPriority NLSOUND::CSourceCommon::_Priority [protected, inherited]
 

Definition at line 107 of file source_common.h.

bool NLSOUND::CSourceCommon::_RelativeMode [protected, inherited]
 

Definition at line 116 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getSourceRelativeMode(), and NLSOUND::CSourceCommon::setSourceRelativeMode().

CSimpleSound* NLSOUND::CSimpleSource::_Sound [private]
 

Definition at line 144 of file simple_source.h.

Referenced by CSimpleSource(), getBuffer(), getSimpleSound(), getSound(), play(), and setDirection().

const bool NLSOUND::CSourceCommon::_Spawn [protected, inherited]
 

Definition at line 128 of file source_common.h.

TSpawnEndCallback NLSOUND::CSourceCommon::_SpawnEndCb [protected, inherited]
 

Definition at line 129 of file source_common.h.

Referenced by play(), stop(), and NLSOUND::CSourceCommon::unregisterSpawnCallBack().

CTrack* NLSOUND::CSimpleSource::_Track [private]
 

Definition at line 150 of file simple_source.h.

Referenced by getTime(), getTrack(), play(), setDirection(), setGain(), setLooping(), setPitch(), setPos(), setRelativeGain(), setSourceRelativeMode(), setVelocity(), and stop().

NLMISC::TStringId NLSOUND::CSourceCommon::_UserVarControler [protected, inherited]
 

An optional user var controler.

Definition at line 134 of file source_common.h.

NLMISC::CVector NLSOUND::CSourceCommon::_Velocity [protected, inherited]
 

Definition at line 112 of file source_common.h.

Referenced by NLSOUND::CSourceCommon::getVelocity(), and NLSOUND::CSourceCommon::setVelocity().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 14:41:32 2004 for NeL by doxygen 1.3.6