From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02394.html | 3070 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3070 insertions(+) create mode 100644 docs/doxygen/nel/a02394.html (limited to 'docs/doxygen/nel/a02394.html') diff --git a/docs/doxygen/nel/a02394.html b/docs/doxygen/nel/a02394.html new file mode 100644 index 00000000..b5d57993 --- /dev/null +++ b/docs/doxygen/nel/a02394.html @@ -0,0 +1,3070 @@ + + +NeL: NLSOUND::CComplexSource class Reference + + + +
+

NLSOUND::CComplexSource Class Reference

#include <complex_source.h> +

+

Inheritance diagram for NLSOUND::CComplexSource: +

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

Detailed Description

+Implemetation class for Complex source. Complex source are source that use a CPatternSound object. +

+ +

+Definition at line 42 of file complex_source.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Source properties

void checkup ()
 Get the source relative mode.

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)
 Get the direction vector.

virtual void setPos (const NLMISC::CVector &pos)
virtual void setRelativeGain (float gain)
 Get the gain.

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 source relative mode.

void onEvent ()
 Mixer event implementation.

void onUpdate ()
 Mixer update implementation.

void playStuf ()
 Do the dirty work of starting to play. Called by play and by setGain or setRelativeGain when the source is muted.

std::vector< USource * > _AllSources
 Get the source relative mode.

uint _DelaySeqIndex
 Get the source relative mode.

float _FadeFactor
 Get the source relative mode.

uint32 _FadeLength
 Get the source relative mode.

bool _LastSparseEvent
 Get the source relative mode.

bool _Muted
CComplexSound_PatternSound
 The reference Sound.

uint _SoundSeqIndex
 Get the source relative mode.

USource_Source1
 Get the source relative mode.

USource_Source2
 Get the source relative mode.

NLMISC::TTime _StartTime1
 Get the source relative mode.

NLMISC::TTime _StartTime2
 Get the source relative mode.

float _TickPerSecond
 Get the source relative mode.


Public Types

enum  TSOURCE_TYPE { SOURCE_SIMPLE, +SOURCE_COMPLEX, +SOURCE_BACKGROUND + }

Public Member Functions

 CComplexSource (CComplexSound *soundPattern=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.

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 setLooping (bool loop)
 Set looping on/off for future playbacks (default: off).

virtual void setPitch (float pitch)
void setPriority (TSoundPriority pr)
 Change the priority of the source.

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

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

 ~CComplexSource ()
 Destructor.

Playback control
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 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::CComplexSource::CComplexSource CComplexSound soundPattern = NULL,
bool  spawn = false,
TSpawnEndCallback  cb = 0,
void *  cbUserParam = 0,
NL3D::CCluster cluster = 0
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 37 of file complex_source.cpp. +

+References _PatternSound, _TickPerSecond, NLSOUND::CSound::getGain(), NLSOUND::CSound::getLooping(), NLSOUND::CSound::getPitch(), NLSOUND::CSound::getPriority(), NLSOUND::CComplexSound::getSoundType(), NLSOUND::CComplexSound::getTicksPerSecond(), nlassert, and NLSOUND::TSpawnEndCallback. +

+

00038 :       CSourceCommon(soundPattern, spawn, cb, cbUserParam, cluster),
+00039         _Source1(NULL),
+00040         _Source2(NULL)
+00041 {
+00042         nlassert(soundPattern->getSoundType() == CSound::SOUND_COMPLEX);
+00043         _PatternSound = static_cast<CComplexSound*>(soundPattern);
+00044 
+00045         // read original parameters
+00046         _Gain = soundPattern->getGain();
+00047         _Pitch = soundPattern->getPitch();
+00048         _Looping = soundPattern->getLooping();
+00049         _Priority = soundPattern->getPriority();
+00050         _TickPerSecond = soundPattern->getTicksPerSecond();
+00051 }
+
+

+ + + + +
+ + + + + + + + + +
NLSOUND::CComplexSource::~CComplexSource  ) 
+
+ + + + + +
+   + + +

+Destructor. +

+ +

+Definition at line 53 of file complex_source.cpp. +

+References _AllSources, NLSOUND::CAudioMixerUser::removeEvents(), and NLSOUND::CAudioMixerUser::unregisterUpdate(). +

+

00054 {
+00055         CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00056         // security
+00057         CAudioMixerUser::instance()->unregisterUpdate(this);
+00058         CAudioMixerUser::instance()->removeEvents(this);
+00059 
+00060         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00061         for (; first != last; ++first)
+00062         {
+00063                 //mixer->removeSource(*first);
+00064                 delete *first;
+00065         }
+00066 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + +
void NLSOUND::CComplexSource::checkup  )  [virtual]
+
+ + + + + +
+   + + +

+Get the source relative mode. +

+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 698 of file complex_source.cpp. +

+References _AllSources, _Muted, _Source1, _Source2, NLSOUND::CSound::getLooping(), NLSOUND::USource::getSound(), NLSOUND::USource::isPlaying(), and NLSOUND::USource::play(). +

+

00699 {
+00700         if (_Muted)
+00701                 return;
+00702 
+00703         if (_Source1 != NULL && _Source1->getSound()->getLooping() && !_Source1->isPlaying())
+00704                 _Source1->play();
+00705         if (_Source2 != NULL && _Source2->getSound()->getLooping() && !_Source2->isPlaying())
+00706                 _Source2->play();
+00707 
+00708         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00709         for (; first != last; ++first)
+00710         {
+00711                 USource *source = *first;
+00712                 if (source != NULL && source->getSound()->getLooping() && !source->isPlaying())
+00713                         source->play();
+00714         }
+00715 }
+
+

+ + + + +
+ + + + + + + + + + +
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 NLSOUND::CSimpleSource::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; }
+
+

+ + + + +
+ + + + + + + + + +
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(), NLSOUND::CSimpleSource::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 }
+
+

+ + + + +
+ + + + + + + + + +
TSoundId NLSOUND::CComplexSource::getSound  )  [virtual]
+
+ + + + + +
+   + + +

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

+ +

+Implements NLSOUND::USource. +

+Definition at line 69 of file complex_source.cpp. +

+References _PatternSound, and NLSOUND::TSoundId. +

+

00070 {
+00071         return _PatternSound;
+00072 }
+
+

+ + + + +
+ + + + + + + + + +
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; }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NLSOUND::CComplexSource::getTime  )  [virtual]
+
+ + + + + +
+   + + +

+Returns the number of milliseconds the source has been playing. +

+ +

+Reimplemented from NLSOUND::CSourceCommon. +

+Definition at line 441 of file complex_source.cpp. +

+References NLMISC::CTime::getLocalTime(), NLMISC::TTime, and uint32. +

+

00442 {
+00443         // evaluate the elapsed time.
+00444         if (!_Playing || _PlayStart == 0)       // not started ?
+00445                 return 0;
+00446 
+00447         TTime now = NLMISC::CTime::getLocalTime();
+00448 
+00449         TTime delta = now - _PlayStart;
+00450 
+00451         return uint32(delta);
+00452 }
+
+

+ + + + +
+ + + + + + + + + + +
TSOURCE_TYPE NLSOUND::CComplexSource::getType void   )  const [inline, private, virtual]
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Implements NLSOUND::CSourceCommon. +

+Definition at line 121 of file complex_source.h. +

+

00121 {return SOURCE_COMPLEX;}
+
+

+ + + + +
+ + + + + + + + + + +
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; }
+
+

+ + + + +
+ + + + + + + + + +
bool NLSOUND::CComplexSource::isPlaying  )  [virtual]
+
+ + + + + +
+   + + +

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

+ +

+Reimplemented from NLSOUND::CSourceCommon. +

+Definition at line 87 of file complex_source.cpp. +

+

00088 {
+00089         return _Playing;
+00090 }
+
+

+ + + + +
+ + + + + + + + + +
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::CComplexSource::onEvent  )  [private, virtual]
+
+ + + + + +
+   + + +

+Mixer event implementation. +

+ +

+Implements NLSOUND::CAudioMixerUser::IMixerEvent. +

+Definition at line 577 of file complex_source.cpp. +

+References _DelaySeqIndex, _LastSparseEvent, _PatternSound, _SoundSeqIndex, _Source1, _Source2, _StartTime1, _StartTime2, _TickPerSecond, NLSOUND::CAudioMixerUser::addEvent(), NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CComplexSound::doFadeOut(), NLSOUND::CComplexSound::getDelaySeq(), NLSOUND::CSound::getDuration(), NLMISC::CTime::getLocalTime(), NLSOUND::CComplexSound::getPatternMode(), NLSOUND::CSound::getPitch(), NLSOUND::CComplexSound::getSound(), NLSOUND::USource::getSound(), NLSOUND::CAudioMixerUser::getSoundId(), NLSOUND::CComplexSound::getSoundSeq(), nlassert, NLSOUND::USource::play(), NLSOUND::CAudioMixerUser::registerUpdate(), NLSOUND::USource::setPitch(), NLSOUND::USource::setPos(), NLSOUND::USource::setPriority(), NLSOUND::USource::setRelativeGain(), stop(), NLMISC::TTime, and uint64. +

+

00578 {
+00579         CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00580         NLMISC::TTime now = NLMISC::CTime::getLocalTime();
+00581 
+00582         switch (_PatternSound->getPatternMode())
+00583         {
+00584         case CComplexSound::MODE_CHAINED:
+00585                 {
+00586                         // either it's time to begin a new xfade, or to end this sound.
+00587                         if (_Source2 != NULL)
+00588                         {
+00589                                 // start new cross fade.?
+00590                                 _StartTime2 = now;
+00591                                 // mute the source2
+00592                                 _Source2->setRelativeGain(0);
+00593                                 _Source2->setPitch(_Source2->getSound()->getPitch() * _Pitch);
+00594                                 _Source2->setPos(_Position);
+00595                                 // start the source 2
+00596                                 _Source2->play();
+00597                                 // register for update.
+00598                                 mixer->registerUpdate(this);
+00599                         }
+00600                         else
+00601                         {
+00602                                 if (_PatternSound->doFadeOut())
+00603                                 {
+00604                                         // set in update list for fade out.
+00605                                         _StartTime2 = now;
+00606                                         mixer->registerUpdate(this);
+00607                                 }
+00608                                 else
+00609                                 {
+00610                                         // end the sound.
+00611 //                                      _Source1->stop();
+00612 //                                      mixer->removeSource(_Source1);
+00613                                         delete _Source1;
+00614                                         _Source1 = NULL;
+00615                                         _Playing = false;
+00616                                 }
+00617                         }
+00618                 }
+00619                 break;
+00620         case CComplexSound::MODE_SPARSE:
+00621                 {
+00622                         if (_Source1 != NULL)
+00623                         {
+00624 //                              _Source1->stop();
+00625 //                              mixer->removeSource(_Source1);
+00626                                 delete _Source1;
+00627                                 _Source1 = NULL;
+00628                         }
+00629 
+00630                         const std::vector<uint32> &delaySeq = _PatternSound->getDelaySeq();
+00631                         const vector<uint32>    &soundSeq = _PatternSound->getSoundSeq();
+00632 
+00633                         if (_Looping && _DelaySeqIndex >= delaySeq.size())
+00634                         {
+00635                                 _DelaySeqIndex = 1;
+00636 /*                              if (!delaySeq.empty() && delaySeq[0] == 0)
+00637                                         _DelaySeqIndex = 1;
+00638                                 else
+00639                                         _DelaySeqIndex = 0;
+00640 */                      }
+00641 
+00642                         if (!soundSeq.empty() && !_LastSparseEvent)
+00643                         {
+00644                                 // wrap around sound sequence until there are delays...
+00645                                 if (_SoundSeqIndex >= soundSeq.size())
+00646                                         _SoundSeqIndex = 0;
+00647 
+00648                                 CSound *sound = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++]));
+00649 
+00650                                 _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster);
+00651                                 if (_Source1 == NULL)
+00652                                 {
+00653                                         stop();
+00654                                         return;
+00655                                 }
+00656                                 _Source1->setPriority(_Priority);
+00657                                 _Source1->setRelativeGain(_Gain*_Gain*_Gain);
+00658                                 _Source1->setPitch(_Source1->getSound()->getPitch() * _Pitch);
+00659                                 _Source1->setPos(_Position);
+00660                                 _Source1->play();
+00661                                 _StartTime1 = now;
+00662 
+00663                                 // register event for next sound.
+00664                                 if (!delaySeq.empty() && _DelaySeqIndex < delaySeq.size())
+00665                                 {
+00666                                         // event for next sound.
+00667                                         mixer->addEvent(this, uint64(now + sound->getDuration() + delaySeq[_DelaySeqIndex++]/_TickPerSecond));
+00668                                         if (_DelaySeqIndex == delaySeq.size() && !_Looping)
+00669                                                 _LastSparseEvent = true;
+00670                                 }
+00671                                 else
+00672                                 {
+00673                                         // event for stop ?
+00674                                         if (!_Looping)
+00675                                                 _LastSparseEvent = true;
+00676                                         else
+00677                                                 _LastSparseEvent = false;
+00678                                         mixer->addEvent(this, now + sound->getDuration());
+00679                                 }
+00680                         }
+00681                         else
+00682                         {
+00683                                 // this is the event for stop !
+00684                                 stop();
+00685                         }
+00686                 }
+00687                 break;
+00688         case CComplexSound::MODE_ALL_IN_ONE:
+00689                 // just call the stop method.
+00690                 stop();
+00691                 break;
+00692         default:
+00693                 nlassert(false);
+00694         }
+00695 }
+
+

+ + + + +
+ + + + + + + + + +
void NLSOUND::CComplexSource::onUpdate  )  [private, virtual]
+
+ + + + + +
+   + + +

+Mixer update implementation. +

+ +

+Implements NLSOUND::CAudioMixerUser::IMixerUpdate. +

+Definition at line 456 of file complex_source.cpp. +

+References _FadeFactor, _FadeLength, _PatternSound, _SoundSeqIndex, _Source1, _Source2, _StartTime1, _StartTime2, _TickPerSecond, NLSOUND::CAudioMixerUser::addEvent(), NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CComplexSound::doFadeOut(), NLSOUND::CSound::getDuration(), NLSOUND::CComplexSound::getFadeLenght(), NLMISC::CTime::getLocalTime(), NLSOUND::CSound::getName(), NLSOUND::CComplexSound::getPatternMode(), NLSOUND::USource::getSound(), NLSOUND::CComplexSound::getSound(), NLSOUND::CAudioMixerUser::getSoundId(), NLSOUND::CComplexSound::getSoundSeq(), nlassert, nldebug, NLSOUND::USource::setRelativeGain(), NLMISC::TTime, uint32, and NLSOUND::CAudioMixerUser::unregisterUpdate(). +

+

00457 {
+00458         // do the cross fade : 
+00459         //      - lower sound1, louder sound2, 
+00460         //      - when max reach, stop the update, swap the sound, delete sound1 and set event for next fade.
+00461 
+00462         // can only occur for chained mode.
+00463         nlassert(_PatternSound->getPatternMode() == CComplexSound::MODE_CHAINED);
+00464 
+00465         CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00466         
+00467         // compute xfade factor.
+00468         TTime now = NLMISC::CTime::getLocalTime();
+00469         if (_FadeLength > 0)
+00470         {
+00471                 _FadeFactor = float((double(now) - double(_StartTime2)) / double(_FadeLength)) ;
+00472 //              _FadeFactor = (_FadeFactor*_FadeFactor);
+00473         }
+00474         else
+00475                 _FadeFactor = 1.0f;
+00476 
+00477 //      nldebug("Fade factor = %f", _FadeFactor);
+00478         if (_FadeFactor >= 1.0)
+00479         {
+00480                 _FadeFactor = 1.0f;
+00481                 // fade end !
+00482                 if (_Source1)
+00483                 {
+00484 //                      _Source1->stop();
+00485 //                      mixer->removeSource(_Source1);
+00486                         delete _Source1;
+00487                         _Source1 = NULL;
+00488                 }
+00489                 if (_Source2)
+00490                 {
+00491                         // set max volume
+00492                         _Source2->setRelativeGain(1.0f * _Gain);
+00493                         // 'swap' the source
+00494                         _Source1 = _Source2;
+00495                         _FadeFactor = 0.0f;
+00496                         _StartTime1 = _StartTime2;
+00497                         _Source2 = NULL;
+00498                         // if there is a next sound available, program an event for the next xfade.
+00499                         CSound  *sound2 = NULL;
+00500 //                      _SoundSeqIndex++;
+00501                         const vector<uint32>    &soundSeq = _PatternSound->getSoundSeq();
+00502                         if (_SoundSeqIndex < soundSeq.size())
+00503                         {
+00504                                 sound2 = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++]));
+00505                         }
+00506                         else if (_Looping)
+00507                         {
+00508                                 // restart the sound sequence
+00509                                 _SoundSeqIndex = 0;
+00510                                 sound2 = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++]));
+00511                         }
+00512                                 
+00513 
+00514                         if (sound2 != NULL)
+00515                         {
+00516                                 nldebug("CS : Chaining to sound %s", CStringMapper::unmap(sound2->getName()).c_str());
+00517                                 CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00518 
+00519                                 // determine the XFade lenght (if next sound is too short.
+00520                                 _FadeLength = minof<uint32>(uint32(_PatternSound->getFadeLenght()/_TickPerSecond), (sound2->getDuration()) / 2, (_Source1->getSound()->getDuration())/2);
+00521                                 _Source2 = mixer->createSource(sound2, false, 0, 0, _Cluster);
+00522                                 if (_Source2)
+00523                                 {
+00524                                         _Source2->setPriority(_Priority);
+00525                                         // there is a next sound, add event for xfade.
+00526                                         nldebug("Seting event for sound %s in %u millisec (XFade = %u).", CStringMapper::unmap(_Source1->getSound()->getName()).c_str(), _Source1->getSound()->getDuration()-_FadeLength, _FadeLength);
+00527                                         mixer->addEvent(this, _StartTime1 + _Source1->getSound()->getDuration() - _FadeLength);
+00528                                 }
+00529                         }
+00530                         else
+00531                         {
+00532                                 // no sound after, just set an event at end of current sound to stop the complex sound.
+00533                                 nldebug("Setting last event for sound %s in %u millisec.", CStringMapper::unmap(_Source1->getSound()->getName()).c_str(), _Source1->getSound()->getDuration());
+00534                                 if (_PatternSound->doFadeOut())
+00535                                 {
+00536                                         // set the event to begin fade out.
+00537                                         mixer->addEvent(this, _StartTime1 + _Source1->getSound()->getDuration() - _PatternSound->getFadeLenght());
+00538                                 }
+00539                                 else
+00540                                 {
+00541                                         // set the event at end of sound.
+00542                                         mixer->addEvent(this, _StartTime1 + _Source1->getSound()->getDuration());
+00543                                 }
+00544                         }
+00545                 }
+00546                 else
+00547                 {
+00548                         if (_PatternSound->doFadeOut())
+00549                         {
+00550                                 // update is responsible for stoping the sound.
+00551                                 _Playing = false;
+00552                         }
+00553                 }
+00554                 // remove from the update list
+00555                 mixer->unregisterUpdate(this);
+00556         }
+00557         else
+00558         {
+00559 //              nldebug("XFade : %4.3f <=> %4.3f (Fade Len = %6.3f", (1.0f-_FadeFactor)*_Gain, _FadeFactor*_Gain, _FadeLength/1000.0f);
+00560 
+00561                 // do the xfade
+00562                 if (_Source1)
+00563                 {
+00564                         // lower the sound 1.
+00565                         _Source1->setRelativeGain((1.0f - _FadeFactor) * _Gain);
+00566 
+00567                 }
+00568                 if (_Source2)
+00569                 {
+00570                         // lower the sound 1.
+00571 //                      _Source2->setRelativeGain(float(sqrt(_FadeFactor)) * _Gain);
+00572                         _Source2->setRelativeGain(_FadeFactor * _Gain);
+00573                 }
+00574         }
+00575 }
+
+

+ + + + +
+ + + + + + + + + +
void NLSOUND::CComplexSource::play  )  [virtual]
+
+ + + + + +
+   + + +

+Play. +

+ +

+Reimplemented from NLSOUND::CSourceCommon. +

+Definition at line 92 of file complex_source.cpp. +

+References _Muted, and playStuf(). +

+

00093 {
+00094         if (_Gain == 0)
+00095         {
+00096                 _Muted = true;
+00097         }
+00098         else
+00099         {
+00100                 playStuf();
+00101         }
+00102         CSourceCommon::play();
+00103 }
+
+

+ + + + +
+ + + + + + + + + +
void NLSOUND::CComplexSource::playStuf  )  [private]
+
+ + + + + +
+   + + +

+Do the dirty work of starting to play. Called by play and by setGain or setRelativeGain when the source is muted. +

+ +

+Definition at line 105 of file complex_source.cpp. +

+References _AllSources, _DelaySeqIndex, _FadeFactor, _FadeLength, _LastSparseEvent, _Muted, _PatternSound, _SoundSeqIndex, _Source1, _Source2, _StartTime1, _StartTime2, _TickPerSecond, NLSOUND::CAudioMixerUser::addEvent(), NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CComplexSound::doFadeIn(), NLSOUND::CComplexSound::getDelaySeq(), NLSOUND::CComplexSound::getDuration(), NLSOUND::CSound::getDuration(), NLSOUND::CComplexSound::getFadeLenght(), NLMISC::CTime::getLocalTime(), NLSOUND::CComplexSound::getPatternMode(), NLSOUND::CSound::getPitch(), NLSOUND::USource::getSound(), NLSOUND::CComplexSound::getSound(), NLSOUND::CAudioMixerUser::getSoundId(), NLSOUND::CComplexSound::getSounds(), NLSOUND::CComplexSound::getSoundSeq(), min, nldebug, NLSOUND::USource::play(), NLSOUND::CAudioMixerUser::registerUpdate(), NLSOUND::USource::setPitch(), NLSOUND::USource::setPos(), NLSOUND::USource::setPriority(), NLSOUND::USource::setRelativeGain(), NLMISC::TTime, uint32, and uint64. +

+Referenced by play(), setGain(), and setRelativeGain(). +

+

00106 {
+00107         CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00108         NLMISC::TTime now = NLMISC::CTime::getLocalTime();
+00109 
+00110         switch (_PatternSound->getPatternMode())
+00111         {
+00112         case CComplexSound::MODE_CHAINED:
+00113                 {
+00114                         _SoundSeqIndex = 0;
+00115                         _FadeFactor = 1.0f;
+00116                         const vector<uint32>    &soundSeq = _PatternSound->getSoundSeq();
+00117                         if (!soundSeq.empty())
+00118                         {
+00119                                 CSound *sound = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++]));
+00120 
+00121                                 if (sound == 0)
+00122                                         return;
+00123                                 
+00124                                 if (_PatternSound->doFadeIn())
+00125                                         _FadeLength = min(uint32(_PatternSound->getFadeLenght()/_TickPerSecond), sound->getDuration() /2);
+00126                                 else
+00127                                         _FadeLength = 0;
+00128 
+00129                                 _Source2 = mixer->createSource(sound, false, 0, 0, _Cluster);
+00130                                 if (_Source2 == NULL)
+00131                                         return;
+00132                                 _Source2->setPriority(_Priority);
+00133                                 _Source2->setRelativeGain(0);
+00134                                 _Source2->setPos(_Position);
+00135                                 _Source2->setPitch(_Source2->getSound()->getPitch() * _Pitch);
+00136                                 _Source2->play();
+00137                                 _StartTime2 = now;
+00138 
+00139                                 // register for fade in.
+00140                                 mixer->registerUpdate(this);
+00141                         }
+00142                 }
+00143                 break;
+00144         case CComplexSound::MODE_SPARSE:
+00145                 {
+00146                         // use Source1, sound sequence, delay sequence and event.
+00147                         _SoundSeqIndex = 0;
+00148                         _DelaySeqIndex = 0;
+00149 
+00150                         const std::vector<uint32> &delaySeq = _PatternSound->getDelaySeq();
+00151 
+00152                         if (!delaySeq.empty() && delaySeq[_DelaySeqIndex] != 0)
+00153                         {
+00154                                 _LastSparseEvent = false;
+00155                                 // begin with a delay
+00156                                 mixer->addEvent(this, uint64(now + delaySeq[_DelaySeqIndex++]/_TickPerSecond));
+00157                         }
+00158                         else
+00159                         {
+00160                                 if (!delaySeq.empty())
+00161                                         _DelaySeqIndex = 1;
+00162                                 const vector<uint32>    &soundSeq = _PatternSound->getSoundSeq();
+00163                                 if (!soundSeq.empty())
+00164                                 {
+00165                                         CSound *sound = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++]));
+00166 
+00167                                         _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster);
+00168                                         if (_Source1 == NULL)
+00169                                                 return;
+00170                                         _Source1->setPriority(_Priority);
+00171                                         _Source1->setRelativeGain(_Gain*_Gain*_Gain);
+00172                                         _Source1->setPos(_Position);
+00173                                         _Source1->setPitch(_Source1->getSound()->getPitch() * _Pitch);
+00174                                         _Source1->play();
+00175                                         _StartTime1 = now;
+00176 
+00177                                         // register event for next sound.
+00178                                         const std::vector<uint32> &delaySeq = _PatternSound->getDelaySeq();
+00179                                         if (!delaySeq.empty() && _DelaySeqIndex < delaySeq.size())
+00180                                         {
+00181                                                 // event for next sound.
+00182                                                 mixer->addEvent(this, uint64(now + sound->getDuration() + delaySeq[_DelaySeqIndex++]/_TickPerSecond));
+00183                                                 if (_DelaySeqIndex >= delaySeq.size() && !_Looping)
+00184                                                         _LastSparseEvent = true;
+00185                                                 else
+00186                                                         _LastSparseEvent = false;
+00187                                         }
+00188                                         else
+00189                                         {
+00190                                                 _LastSparseEvent = true;
+00191                                                 // event for stop
+00192                                                 mixer->addEvent(this, now + sound->getDuration());
+00193                                         }
+00194                                 }
+00195                         }
+00196 
+00197                 }
+00198                 break;
+00199         case CComplexSound::MODE_ALL_IN_ONE:
+00200                 {
+00201                         // just spanw all the listed source.
+00202                         const std::vector<NLMISC::TStringId> &sounds = _PatternSound->getSounds();
+00203 
+00204                         std::vector<NLMISC::TStringId>::const_iterator first(sounds.begin()), last(sounds.end());
+00205 
+00206                         if (_AllSources.empty())
+00207                         {
+00208                                 // create the sources
+00209                                 for (; first != last; ++first)
+00210                                 {
+00211                                         CSound *sound = mixer->getSoundId(*first);
+00212                                         if (sound != NULL)
+00213                                         {
+00214                                                 USource *source = mixer->createSource(sound, false, 0, 0, _Cluster);
+00215                                                 if (source != NULL)
+00216                                                 {
+00217                                                         source->setPriority(_Priority);
+00218                                                         source->setRelativeGain(_Gain*_Gain*_Gain);
+00219                                                         source->setPos(_Position);
+00220                                                         source->setPitch(source->getSound()->getPitch() * _Pitch);
+00221                                                         source->play();
+00222                                                         
+00223                                                         _AllSources.push_back(source);
+00224                                                 }
+00225                                         }
+00226                                 }
+00227                         }
+00228                         else
+00229                         {
+00230                                 // just replay the existing source.
+00231                                 std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00232 
+00233                                 for (; first != last; ++first)
+00234                                 {
+00235                                         (*first)->setRelativeGain(_Gain*_Gain*_Gain);
+00236                                         (*first)->setPos(_Position);
+00237                                         (*first)->setPitch((*first)->getSound()->getPitch() * _Pitch);
+00238                                         (*first)->play();
+00239                                 }
+00240                         }
+00241 
+00242                         if (!_Looping)
+00243                         {
+00244                                 // event to stop the sound
+00245                                 mixer->addEvent(this, NLMISC::CTime::getLocalTime() + _PatternSound->getDuration());
+00246                         }
+00247                 }
+00248                 break;
+00249         default:
+00250                 nldebug("Unknow pattern mode. Can't play.");
+00251         }
+00252 
+00253         _Muted = false;
+00254 }
+
+

+ + + + +
+ + + + + + + + + + +
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::CComplexSource::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 338 of file complex_source.cpp. +

+References _AllSources, _Source1, _Source2, and NLSOUND::USource::setDirection(). +

+

00339 {
+00340         CSourceCommon::setDirection(dir);
+00341         
+00342         if (_Source1 != NULL)
+00343                 _Source1->setDirection(dir);
+00344         if (_Source2 != NULL)
+00345                 _Source2->setDirection(dir);
+00346 
+00347         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00348         for (; first != last; ++first)
+00349         {
+00350                 (*first)->setDirection(dir);
+00351         }
+00352 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CComplexSource::setGain float  gain  )  [virtual]
+
+ + + + + +
+   + + +

+Get the direction vector. +

+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 358 of file complex_source.cpp. +

+References _AllSources, _FadeFactor, _Muted, _PatternSound, _Source1, _Source2, NLSOUND::CComplexSound::getPatternMode(), playStuf(), and NLSOUND::USource::setRelativeGain(). +

+

00359 {
+00360         CSourceCommon::setGain(gain);
+00361 
+00362         // update the gain of the played source.
+00363         if (_PatternSound->getPatternMode() == CComplexSound::MODE_CHAINED)
+00364         {
+00365                 // set sub source volume with fade value.
+00366                 if (_Source1 != NULL)
+00367                         _Source1->setRelativeGain((1.0f - _FadeFactor) * _Gain*_Gain*_Gain);
+00368                 if (_Source2 != NULL)
+00369                         _Source2->setRelativeGain(_FadeFactor * _Gain*_Gain*_Gain);
+00370 
+00371         }
+00372         else
+00373         {
+00374                 if (_Source1 != NULL)
+00375                         _Source1->setRelativeGain(_Gain*_Gain*_Gain);
+00376                 if (_Source2 != NULL)
+00377                         _Source2->setRelativeGain(_Gain*_Gain*_Gain);
+00378         }
+00379 
+00380         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00381         for (; first != last; ++first)
+00382         {
+00383                 (*first)->setGain(_Gain);
+00384         }
+00385 
+00386         if (_Muted && _Playing)
+00387                 playStuf();
+00388 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CSourceCommon::setLooping bool  loop  )  [virtual, inherited]
+
+ + + + + +
+   + + +

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

+ +

+Implements NLSOUND::USource. +

+Reimplemented in NLSOUND::CSimpleSource. +

+Definition at line 91 of file source_common.cpp. +

+

00092 {
+00093         _Looping = l;
+00094 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CSourceCommon::setPitch float  pitch  )  [virtual, inherited]
+
+ + + + + +
+   + + +

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

+Implements NLSOUND::USource. +

+Reimplemented in NLSOUND::CSimpleSource. +

+Definition at line 157 of file source_common.cpp. +

+Referenced by NLSOUND::CAudioMixerUser::addUserControledSource(). +

+

00158 {
+00159 //      nlassert( (pitch > 0) && (pitch <= 1.0f ) );
+00160         _Pitch = pitch;
+00161 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CComplexSource::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 303 of file complex_source.cpp. +

+References _AllSources, _Source1, _Source2, and NLSOUND::USource::setPos(). +

+

00304 {
+00305         CSourceCommon::setPos(pos);
+00306         
+00307         if (_Source1 != NULL)
+00308                 _Source1->setPos(pos);
+00309         if (_Source2 != NULL)
+00310                 _Source2->setPos(pos);
+00311 
+00312         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00313         for (; first != last; ++first)
+00314         {
+00315                 (*first)->setPos(pos);
+00316         }
+00317 }
+
+

+ + + + +
+ + + + + + + + + + +
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::CComplexSource::setRelativeGain float  gain  )  [virtual]
+
+ + + + + +
+   + + +

+Get the gain. +

+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 390 of file complex_source.cpp. +

+References _AllSources, _FadeFactor, _Muted, _PatternSound, _Source1, _Source2, NLSOUND::CComplexSound::getPatternMode(), playStuf(), and NLSOUND::USource::setRelativeGain(). +

+

00391 {
+00392         CSourceCommon::setRelativeGain(gain);
+00393 
+00394         // update the gain of the played source.
+00395         if (_PatternSound->getPatternMode() == CComplexSound::MODE_CHAINED)
+00396         {
+00397                 // set sub source volume with fade value.
+00398                 if (_Source1 != NULL)
+00399                         _Source1->setRelativeGain((1.0f - _FadeFactor) * _Gain*_Gain*_Gain);
+00400                 if (_Source2 != NULL)
+00401                         _Source2->setRelativeGain(_FadeFactor * _Gain*_Gain*_Gain);
+00402 
+00403         }
+00404         else
+00405         {
+00406                 if (_Source1 != NULL)
+00407                         _Source1->setRelativeGain(_Gain*_Gain*_Gain);
+00408                 if (_Source2 != NULL)
+00409                         _Source2->setRelativeGain(_Gain*_Gain*_Gain);
+00410         }
+00411 
+00412         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00413         for (; first != last; ++first)
+00414         {
+00415                 (*first)->setRelativeGain(_Gain);
+00416         }
+00417 
+00418         if (_Muted && _Playing)
+00419                 playStuf();
+00420 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CSourceCommon::setSourceRelativeMode bool  mode  )  [virtual, inherited]
+
+ + + + + +
+   + + +

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

+ +

+Implements NLSOUND::USource. +

+Reimplemented in NLSOUND::CSimpleSource. +

+Definition at line 216 of file source_common.cpp. +

+References NLSOUND::CSourceCommon::_RelativeMode. +

+

00217 {
+00218         _RelativeMode = mode;
+00219 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLSOUND::CComplexSource::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 319 of file complex_source.cpp. +

+References _AllSources, _Source1, _Source2, and NLSOUND::USource::setVelocity(). +

+

00320 {
+00321         CSourceCommon::setVelocity(vel);
+00322         
+00323         if (_Source1 != NULL)
+00324                 _Source1->setVelocity(vel);
+00325         if (_Source2 != NULL)
+00326                 _Source2->setVelocity(vel);
+00327 
+00328         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00329         for (; first != last; ++first)
+00330         {
+00331                 (*first)->setVelocity(vel);
+00332         }
+00333 }
+
+

+ + + + +
+ + + + + + + + + +
void NLSOUND::CComplexSource::stop  )  [virtual]
+
+ + + + + +
+   + + +

+Stop playing. +

+ +

+Reimplemented from NLSOUND::CSourceCommon. +

+Definition at line 255 of file complex_source.cpp. +

+References _AllSources, _PatternSound, _Source1, _Source2, NLSOUND::CComplexSound::getPatternMode(), NLSOUND::CAudioMixerUser::removeEvents(), NLSOUND::USource::stop(), and NLSOUND::CAudioMixerUser::unregisterUpdate(). +

+Referenced by onEvent(). +

+

00256 {
+00257         CAudioMixerUser *mixer = CAudioMixerUser::instance();
+00258         if (_Source1)
+00259         {
+00260 //              _Source1->stop();
+00261 //              mixer->removeSource(_Source1);
+00262                 delete _Source1;
+00263 
+00264                 _Source1 = NULL;
+00265         }
+00266         if (_Source2)
+00267         {
+00268 //              _Source2->stop();
+00269 //              mixer->removeSource(_Source2);
+00270                 delete _Source2;
+00271 
+00272                 _Source2 = NULL;
+00273         }
+00274 
+00275         std::vector<USource     *>::iterator first(_AllSources.begin()), last(_AllSources.end());
+00276         for (; first != last; ++first)
+00277         {
+00278                 if ((*first)->isPlaying())
+00279                         (*first)->stop();
+00280                 delete *first;
+00281         }
+00282         _AllSources.clear();
+00283 
+00284         switch (_PatternSound->getPatternMode())
+00285         {
+00286         case CComplexSound::MODE_CHAINED:
+00287                 mixer->unregisterUpdate(this);
+00288                 mixer->removeEvents(this);
+00289                 break;
+00290         case CComplexSound::MODE_SPARSE:
+00291         case CComplexSound::MODE_ALL_IN_ONE:
+00292                 mixer->removeEvents(this);
+00293                 break;
+00294         }
+00295 
+00296         CSourceCommon::stop();
+00297 }
+
+

+ + + + +
+ + + + + + + + + +
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().

+

+ + + + +
+ + +
std::vector<USource *> NLSOUND::CComplexSource::_AllSources [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 133 of file complex_source.h. +

+Referenced by checkup(), playStuf(), setDirection(), setGain(), setPos(), setRelativeGain(), setVelocity(), stop(), and ~CComplexSource().

+

+ + + + +
+ + +
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().

+

+ + + + +
+ + +
uint NLSOUND::CComplexSource::_DelaySeqIndex [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 153 of file complex_source.h. +

+Referenced by onEvent(), and playStuf().

+

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

+ +

+Definition at line 113 of file source_common.h.

+

+ + + + +
+ + +
float NLSOUND::CComplexSource::_FadeFactor [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 150 of file complex_source.h. +

+Referenced by onUpdate(), playStuf(), setGain(), and setRelativeGain().

+

+ + + + +
+ + +
uint32 NLSOUND::CComplexSource::_FadeLength [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 148 of file complex_source.h. +

+Referenced by onUpdate(), and playStuf().

+

+ + + + +
+ + +
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::CComplexSource::_LastSparseEvent [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 155 of file complex_source.h. +

+Referenced by onEvent(), and playStuf().

+

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

+ +

+Definition at line 109 of file source_common.h.

+

+ + + + +
+ + +
bool NLSOUND::CComplexSource::_Muted [private] +
+
+ + + + + +
+   + + +

+When play is called but the gain is 0, then the sound is muted. This flag keek track of this to restart the source when the gain is updated. +

+Definition at line 139 of file complex_source.h. +

+Referenced by checkup(), play(), playStuf(), setGain(), and setRelativeGain().

+

+ + + + +
+ + +
CComplexSound* NLSOUND::CComplexSource::_PatternSound [private] +
+
+ + + + + +
+   + + +

+The reference Sound. +

+ +

+Definition at line 158 of file complex_source.h. +

+Referenced by CComplexSource(), getSound(), onEvent(), onUpdate(), playStuf(), setGain(), setRelativeGain(), and stop().

+

+ + + + +
+ + +
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.

+

+ + + + +
+ + +
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().

+

+ + + + +
+ + +
uint NLSOUND::CComplexSource::_SoundSeqIndex [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 152 of file complex_source.h. +

+Referenced by onEvent(), onUpdate(), and playStuf().

+

+ + + + +
+ + +
USource* NLSOUND::CComplexSource::_Source1 [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 130 of file complex_source.h. +

+Referenced by checkup(), onEvent(), onUpdate(), playStuf(), setDirection(), setGain(), setPos(), setRelativeGain(), setVelocity(), and stop().

+

+ + + + +
+ + +
USource* NLSOUND::CComplexSource::_Source2 [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 131 of file complex_source.h. +

+Referenced by checkup(), onEvent(), onUpdate(), playStuf(), setDirection(), setGain(), setPos(), setRelativeGain(), setVelocity(), and stop().

+

+ + + + +
+ + +
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 NLSOUND::CSimpleSource::play(), NLSOUND::CSimpleSource::stop(), and NLSOUND::CSourceCommon::unregisterSpawnCallBack().

+

+ + + + +
+ + +
NLMISC::TTime NLSOUND::CComplexSource::_StartTime1 [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 144 of file complex_source.h. +

+Referenced by onEvent(), onUpdate(), and playStuf().

+

+ + + + +
+ + +
NLMISC::TTime NLSOUND::CComplexSource::_StartTime2 [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 145 of file complex_source.h. +

+Referenced by onEvent(), onUpdate(), and playStuf().

+

+ + + + +
+ + +
float NLSOUND::CComplexSource::_TickPerSecond [private] +
+
+ + + + + +
+   + + +

+Get the source relative mode. +

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

+Definition at line 147 of file complex_source.h. +

+Referenced by CComplexSource(), onEvent(), onUpdate(), and playStuf().

+

+ + + + +
+ + +
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:37:11 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1