NLSOUND::CComplexSound Class Reference

#include <complex_sound.h>

Inheritance diagram for NLSOUND::CComplexSound:

NLSOUND::CSound

Public Types

enum  TPATTERN_MODE { MODE_UNDEFINED, MODE_CHAINED, MODE_ALL_IN_ONE, MODE_SPARSE }
enum  TSOUND_TYPE { SOUND_SIMPLE, SOUND_COMPLEX, SOUND_BACKGROUND, SOUND_CONTEXT }

Public Member Functions

 CComplexSound ()
bool doFadeIn ()
bool doFadeOut ()
float getConeInnerAngle () const
 Return the inner angle of the cone.

float getConeOuterAngle () const
 Return the outer angle of the cone.

float getConeOuterGain () const
 Return the outer gain of the cone.

const std::vector< uint32 > & getDelaySeq () const
const NLMISC::CVectorgetDirectionVector () const
 Return the direction vector.

uint32 getDuration ()
 Return the length of the sound in ms.

uint32 getFadeLenght () const
float getGain () const
 Return the gain.

bool getLooping () const
 Return the looping state.

const NLMISC::TStringIdgetName () const
 Return the name (must be unique).

TPATTERN_MODE getPatternMode ()
float getPitch () const
 Return the pitch.

TSoundPriority getPriority () const
 Return the initial priority.

NLMISC::TStringId getSound (uint index) const
const std::vector< NLMISC::TStringId > & getSounds () const
const std::vector< uint32 > & getSoundSeq () const
TSOUND_TYPE getSoundType ()
 Get the type of the sound.

void getSubSoundList (std::vector< std::pair< std::string, CSound * > > &subsounds) const
 Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).

NLMISC::TStringId getUserVarControler ()
virtual void importForm (const std::string &filename, NLGEORGES::UFormElm &formRoot)
 Load the sound parameters from georges' form.

bool isDetailed () const
 Return true if cone is meaningful.

bool operator< (const CSound &otherSound) const
void serial (NLMISC::IStream &s)
void setLooping (bool looping)
 Set looping.

void setPatternMode (TPATTERN_MODE patternMode)
virtual ~CComplexSound ()
Tempo
virtual float getTicksPerSecond ()
virtual void setTicksPerSecond (float ticks)

Static Public Member Functions

CSoundcreateSound (const std::string &filename, NLGEORGES::UFormElm &formRoot)
 Factory for specialized sound.


Protected Attributes

float _ConeInnerAngle
float _ConeOuterAngle
float _ConeOuterGain
NLMISC::CVector _Direction
float _Gain
bool _Looping
float _MaxDist
 Clipping distance for complex or backgound sound.

NLMISC::TStringId _Name
float _Pitch
TSoundPriority _Priority
NLMISC::TStringId _UserVarControler
 An optional user var controler.


Private Member Functions

virtual float getMaxDistance () const
 Return the max distance (if detailed()).

void parseSequence (const std::string &str, std::vector< uint32 > &seq, uint scale=1)

Private Attributes

std::vector< uint32_DelaySeq
 Sequence of delay in millisec.

bool _DoFadeIn
 Flag for fade in.

bool _DoFadeOut
 Flag for fade out (only on normal termination, not explicit stop).

uint32 _Duration
bool _DurationValid
bool _MaxDistValid
TPATTERN_MODE _PatternMode
std::vector< NLMISC::TStringId_Sounds
std::vector< uint32_SoundSeq
float _TicksPerSeconds
uint32 _XFadeLenght
 Duration of xfade in millisec.


Member Enumeration Documentation

enum NLSOUND::CComplexSound::TPATTERN_MODE
 

Enumeration values:
MODE_UNDEFINED 
MODE_CHAINED 
MODE_ALL_IN_ONE 
MODE_SPARSE 

Definition at line 47 of file complex_sound.h.

Referenced by getPatternMode().

00048         {
00049                 MODE_UNDEFINED,
00050                 MODE_CHAINED,
00051                 MODE_ALL_IN_ONE,
00052                 MODE_SPARSE
00053         };

enum NLSOUND::CSound::TSOUND_TYPE [inherited]
 

Enumeration values:
SOUND_SIMPLE 
SOUND_COMPLEX 
SOUND_BACKGROUND 
SOUND_CONTEXT 

Definition at line 67 of file sound.h.

00068         {
00069                 SOUND_SIMPLE,
00070                 SOUND_COMPLEX,
00071                 SOUND_BACKGROUND,
00072                 SOUND_CONTEXT
00073         };


Constructor & Destructor Documentation

NLSOUND::CComplexSound::CComplexSound  ) 
 

Constructor

Definition at line 151 of file complex_sound.cpp.

00152 :       _MaxDistValid(false),
00153         _TicksPerSeconds(1.0f),
00154         _PatternMode(CComplexSound::MODE_UNDEFINED),
00155         _DurationValid(false),
00156         _Duration(0),
00157         _XFadeLenght(3000)              // defualt to 3000 sec.
00158 {
00159 }

NLSOUND::CComplexSound::~CComplexSound  )  [virtual]
 

Destructor

Definition at line 163 of file complex_sound.cpp.

00164 {
00165 /*      if (_VolumeEnvelope != 0)
00166         {
00167                 delete _VolumeEnvelope;
00168         }
00169 
00170         if (_FreqModulation != 0)
00171         {
00172                 delete _FreqModulation;
00173         }
00174 */
00175 }


Member Function Documentation

CSound * NLSOUND::CSound::createSound const std::string &  filename,
NLGEORGES::UFormElm formRoot
[static, inherited]
 

Factory for specialized sound.

Definition at line 43 of file sound.cpp.

References NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), NLSOUND::CSound::importForm(), nlassertex, and nlwarning.

00044 {
00045         NL_ALLOC_CONTEXT(NLSOUND_CSound);
00046         CSound *ret = NULL;
00047         string  soundType;
00048 
00049         NLGEORGES::UFormElm *psoundType;
00050 
00051         if (!formRoot.getNodeByName(&psoundType, ".SoundType"))
00052         {
00053                 nlwarning("No SoundType in : %s", filename.c_str());
00054                 return 0;
00055         }
00056 
00057         if (psoundType != NULL)
00058         {
00059                 std::string dfnName;
00060                 psoundType->getDfnName(dfnName);
00061 
00062                 if (dfnName == "simple_sound.dfn")
00063                 {
00064                         ret = new CSimpleSound();
00065                         ret->importForm(filename, formRoot);
00066                 }
00067                 else if (dfnName == "complex_sound.dfn")
00068                 {
00069                         ret = new CComplexSound();
00070                         ret->importForm(filename, formRoot);
00071                 }
00072                 else if (dfnName == "background_sound.dfn")
00073                 {
00074                         ret = new CBackgroundSound();
00075                         ret->importForm(filename, formRoot);
00076                 }
00077                 else if (dfnName == "context_sound.dfn")
00078                 {
00079                         ret = new CContextSound();
00080                         ret->importForm(filename, formRoot);
00081                 }
00082                 else
00083                 {
00084                         nlassertex(false, ("SoundType unsuported : %s", dfnName.c_str()));
00085                 }
00086                         
00087         }
00088 
00089         return ret;
00090 }

bool NLSOUND::CComplexSound::doFadeIn  )  [inline]
 

Definition at line 87 of file complex_sound.h.

References _DoFadeIn.

Referenced by NLSOUND::CComplexSource::playStuf().

00087 { return _DoFadeIn; }

bool NLSOUND::CComplexSound::doFadeOut  )  [inline]
 

Definition at line 88 of file complex_sound.h.

References _DoFadeOut.

Referenced by NLSOUND::CComplexSource::onEvent(), and NLSOUND::CComplexSource::onUpdate().

00088 { return _DoFadeOut; }

float NLSOUND::CSound::getConeInnerAngle  )  const [inline, inherited]
 

Return the inner angle of the cone.

Definition at line 98 of file sound.h.

References NLSOUND::CSound::_ConeInnerAngle.

Referenced by NLSOUND::CSimpleSource::setDirection().

00098 { return _ConeInnerAngle; }

float NLSOUND::CSound::getConeOuterAngle  )  const [inline, inherited]
 

Return the outer angle of the cone.

Definition at line 100 of file sound.h.

References NLSOUND::CSound::_ConeOuterAngle.

Referenced by NLSOUND::CSimpleSource::setDirection().

00100 { return _ConeOuterAngle; }

float NLSOUND::CSound::getConeOuterGain  )  const [inline, inherited]
 

Return the outer gain of the cone.

Definition at line 102 of file sound.h.

References NLSOUND::CSound::_ConeOuterGain.

Referenced by NLSOUND::CSimpleSource::setDirection().

00102 { return _ConeOuterGain; }

const std::vector<uint32>& NLSOUND::CComplexSound::getDelaySeq  )  const [inline]
 

Definition at line 63 of file complex_sound.h.

References _DelaySeq.

Referenced by NLSOUND::CComplexSource::onEvent(), and NLSOUND::CComplexSource::playStuf().

00063 { return _DelaySeq;}

const NLMISC::CVector& NLSOUND::CSound::getDirectionVector  )  const [inline, inherited]
 

Return the direction vector.

Definition at line 104 of file sound.h.

00104 { return _Direction;}

uint32 NLSOUND::CComplexSound::getDuration  )  [virtual]
 

Return the length of the sound in ms.

Implements NLSOUND::CSound.

Definition at line 56 of file complex_sound.cpp.

References _DelaySeq, _PatternMode, _SoundSeq, _TicksPerSeconds, _XFadeLenght, NLSOUND::CSound::getDuration(), NLSOUND::CAudioMixerUser::getSoundId(), MODE_ALL_IN_ONE, MODE_CHAINED, MODE_SPARSE, sint32, uint, and uint32.

Referenced by NLSOUND::CComplexSource::playStuf().

00057 {
00058         // evaluate the duration of the sound...
00059 
00060         if (_DurationValid)
00061                 return _Duration;
00062 
00063         // catch the duration of all sub sound.
00064         CAudioMixerUser *mixer = CAudioMixerUser::instance();
00065 
00066         vector<sint32>  durations;
00067         std::vector<NLMISC::TStringId>::iterator first(_Sounds.begin()), last(_Sounds.end());
00068         for (; first != last; ++first)
00069         {
00070                 CSound *sound = mixer->getSoundId(*first);
00071                 if (sound != NULL)
00072                 {
00073                         durations.push_back(sint32(sound->getDuration()));
00074                 }
00075                 else
00076                         durations.push_back(0);
00077                         
00078         }
00079 
00080         _Duration = 0;
00081         switch (_PatternMode)
00082         {
00083         case MODE_CHAINED:
00084                 {
00085                         // sum the duration minus the xfade time (this is an aproximation if sample are shorter than 2 xfade time)
00086                         vector<uint32>::iterator first(_SoundSeq.begin()), last(_SoundSeq.end()), prev;
00087                         for (; first != last; ++first)
00088                         {
00089                                 if (first != _SoundSeq.begin() && !durations.empty())
00090                                 {
00091                                         // remove a xfade value
00092                                         _Duration -= minof<uint32>(uint32(_XFadeLenght / _TicksPerSeconds), durations[*first % durations.size()] / 2, durations[*prev % durations.size()] /2);
00093                                 }
00094                                 if (!durations.empty())
00095                                         _Duration += durations[*first % durations.size()];
00096                                 prev = first;
00097                         }
00098 //                      _Duration -= max(sint(0), sint(_XFadeLenght * (_SoundSeq.size()-2)  ));
00099                 }
00100                 break;
00101         case MODE_SPARSE:
00102                 {
00103                         if (_SoundSeq.empty())
00104                                 _Duration = 0;
00105                         else if (_DelaySeq.empty())
00106                         {
00107                                 _Duration = durations[0];
00108                         }
00109                         else if (_DelaySeq.size() == 1)
00110                         {
00111                                 _Duration = durations[0] + _DelaySeq[0];
00112                         }
00113                         else
00114                         {
00115                                 uint soundIndex = 0;
00116                                 _Duration = 0; //durations[soundIndex++];
00117 
00118                                 std::vector<uint32>::iterator first(_DelaySeq.begin()), last(_DelaySeq.end());
00119 
00120                                 _Duration+= *first;
00121                                 ++first;
00122                                 for (; first != last; ++first)
00123                                 {
00124                                         // add the sound lenght
00125                                         _Duration += durations[soundIndex++ % durations.size()];
00126                                         // add the delay
00127                                         _Duration += uint32(*first / _TicksPerSeconds);
00128                                 }
00129                         }
00130                 }
00131                 break;
00132         case MODE_ALL_IN_ONE:
00133                 // only find the longueur sound.
00134                 if (!durations.empty())
00135                         _Duration = *(std::max_element(durations.begin(), durations.end()));
00136                 else
00137                         _Duration = 0;
00138                 break;
00139         default:
00140                 return 0;
00141         }
00142 
00143         _DurationValid = true;
00144         return _Duration;
00145 
00146 }

uint32 NLSOUND::CComplexSound::getFadeLenght  )  const [inline]
 

Definition at line 67 of file complex_sound.h.

References _XFadeLenght, and uint32.

Referenced by NLSOUND::CComplexSource::onUpdate(), and NLSOUND::CComplexSource::playStuf().

00067 { return _XFadeLenght;} 

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

Return the gain.

Definition at line 90 of file sound.h.

Referenced by NLSOUND::CAudioMixerUser::addUserControledSource(), NLSOUND::CComplexSource::CComplexSource(), NLSOUND::CAudioMixerUser::createSource(), and NLSOUND::CBackgroundSource::updateFilterValues().

00090 { return _Gain; }

bool NLSOUND::CSound::getLooping  )  const [inline, inherited]
 

Return the looping state.

Definition at line 88 of file sound.h.

References NLSOUND::CSound::_Looping.

Referenced by NLSOUND::CComplexSource::CComplexSource(), and NLSOUND::CComplexSource::checkup().

00088 { return _Looping; }

float NLSOUND::CComplexSound::getMaxDistance  )  const [private, virtual]
 

Return the max distance (if detailed()).

Reimplemented from NLSOUND::CSound.

Definition at line 177 of file complex_sound.cpp.

References NLSOUND::CSound::_MaxDist, _MaxDistValid, NLSOUND::CSound::getMaxDistance(), and NLSOUND::CAudioMixerUser::getSoundId().

00178 {
00179         if (!_MaxDistValid)
00180         {
00181                 // compute the max distance by checking the max distance of all sounds.
00182                 CAudioMixerUser *mixer = CAudioMixerUser::instance();
00183 
00184                 // Hum, getMaxDistance is const, but we must compute the real max dist and update it !
00185                 CComplexSound *This = const_cast<CComplexSound*>(this);
00186 
00187                 This->_MaxDist = 0.0f;
00188                 std::vector<NLMISC::TStringId>::const_iterator first(_Sounds.begin()), last(_Sounds.end());
00189 
00190                 for (; first != last; ++first)
00191                 {
00192                         CSound *sound = mixer->getSoundId(*first);
00193                         if( sound != NULL)
00194                         {
00195                                 This->_MaxDist = max(_MaxDist, sound->getMaxDistance());
00196                         }
00197                 }
00198                 // security check.
00199                 if (_MaxDist == 0.0f)
00200                         This->_MaxDist = 1000000.0f;
00201         }
00202 
00203         _MaxDistValid = true;
00204         return _MaxDist;
00205 }

const NLMISC::TStringId& NLSOUND::CSound::getName void   )  const [inline, inherited]
 

Return the name (must be unique).

Definition at line 108 of file sound.h.

Referenced by NLSOUND::CSoundBank::addSound(), NLSOUND::CContextSoundContainer< NbJoker, UseRandom, Shift >::addSound(), and NLSOUND::CComplexSource::onUpdate().

00108 { return _Name; }

TPATTERN_MODE NLSOUND::CComplexSound::getPatternMode  )  [inline]
 

Definition at line 59 of file complex_sound.h.

References _PatternMode, and TPATTERN_MODE.

Referenced by NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::onUpdate(), NLSOUND::CComplexSource::playStuf(), NLSOUND::CComplexSource::setGain(), NLSOUND::CComplexSource::setRelativeGain(), and NLSOUND::CComplexSource::stop().

00059 { return _PatternMode;}

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

Return the pitch.

Definition at line 92 of file sound.h.

Referenced by NLSOUND::CComplexSource::CComplexSource(), NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::playStuf(), and NLSOUND::CBackgroundSource::updateFilterValues().

00092 { return _Pitch; }

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

Return the initial priority.

Definition at line 94 of file sound.h.

References NLSOUND::CSound::_Priority, and NLSOUND::TSoundPriority.

Referenced by NLSOUND::CComplexSource::CComplexSource().

00094 { return _Priority; }

NLMISC::TStringId NLSOUND::CComplexSound::getSound uint  index  )  const [inline]
 

Definition at line 64 of file complex_sound.h.

References index, and uint.

Referenced by NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::onUpdate(), and NLSOUND::CComplexSource::playStuf().

00064 { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]: NULL;}

const std::vector<NLMISC::TStringId>& NLSOUND::CComplexSound::getSounds  )  const [inline]
 

Definition at line 65 of file complex_sound.h.

Referenced by NLSOUND::CComplexSource::playStuf().

00065 { return _Sounds;}

const std::vector<uint32>& NLSOUND::CComplexSound::getSoundSeq  )  const [inline]
 

Definition at line 62 of file complex_sound.h.

References _SoundSeq.

Referenced by NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::onUpdate(), and NLSOUND::CComplexSource::playStuf().

00062 { return _SoundSeq;}

TSOUND_TYPE NLSOUND::CComplexSound::getSoundType  )  [inline, virtual]
 

Get the type of the sound.

Implements NLSOUND::CSound.

Definition at line 84 of file complex_sound.h.

Referenced by NLSOUND::CComplexSource::CComplexSource().

00084 {return SOUND_COMPLEX;};

void NLSOUND::CComplexSound::getSubSoundList std::vector< std::pair< std::string, CSound * > > &  subsounds  )  const [virtual]
 

Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).

Implements NLSOUND::CSound.

Definition at line 44 of file complex_sound.cpp.

References NLSOUND::CAudioMixerUser::getSoundId().

00045 {
00046         CAudioMixerUser *mixer = CAudioMixerUser::instance();
00047         std::vector<NLMISC::TStringId>::const_iterator first(_Sounds.begin()), last(_Sounds.end());
00048         for (; first != last; ++first)
00049         {
00050                 CSound *sound = mixer->getSoundId(*first);
00051                 subsounds.push_back(make_pair(CStringMapper::unmap(*first), sound));
00052         }
00053 }

virtual float NLSOUND::CComplexSound::getTicksPerSecond  )  [inline, virtual]
 

Definition at line 80 of file complex_sound.h.

References _TicksPerSeconds.

Referenced by NLSOUND::CComplexSource::CComplexSource().

00080 { return _TicksPerSeconds; }

NLMISC::TStringId NLSOUND::CSound::getUserVarControler  )  [inline, inherited]
 

Definition at line 121 of file sound.h.

References NLSOUND::CSound::_UserVarControler.

00121 { return _UserVarControler; }

void NLSOUND::CComplexSound::importForm const std::string &  filename,
NLGEORGES::UFormElm formRoot
[virtual]
 

Load the sound parameters from georges' form.

Reimplemented from NLSOUND::CSound.

Definition at line 246 of file complex_sound.cpp.

References _DelaySeq, _DoFadeIn, _DoFadeOut, _PatternMode, _SoundSeq, _TicksPerSeconds, _XFadeLenght, NLGEORGES::UFormElm::getArraySize(), NLGEORGES::UFormElm::getArrayValue(), NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), NLGEORGES::UFormElm::getValueByName(), MODE_ALL_IN_ONE, MODE_CHAINED, MODE_SPARSE, nlassert, nlassertex, parseSequence(), size, and uint.

00247 {
00248         NLGEORGES::UFormElm *psoundType;
00249         std::string dfnName;
00250 
00251         _DurationValid = false;
00252 
00253         // some basic checking.
00254         formRoot.getNodeByName(&psoundType, ".SoundType");
00255         nlassert(psoundType != NULL);
00256         psoundType->getDfnName(dfnName);
00257         nlassert(dfnName == "complex_sound.dfn");
00258 
00259         // Call the base class
00260         CSound::importForm(filename, formRoot);
00261 
00262         // Beat per second.
00263         formRoot.getValueByName(_TicksPerSeconds, ".SoundType.Beat");
00264         //beat can't be null or negative! 
00265         if (_TicksPerSeconds <= 0.0f)
00266                 _TicksPerSeconds = 1.0f;
00267 
00268 
00269 
00270         // List of sound int this pattern
00271         NLGEORGES::UFormElm     *psoundsArray;
00272         _Sounds.clear();
00273         formRoot.getNodeByName(&psoundsArray, ".SoundType.SoundList");
00274 
00275         if (psoundsArray != NULL)
00276         {
00277                 uint size;
00278                 psoundsArray->getArraySize(size);
00279                 for (uint i=0; i<size; ++i)
00280                 {
00281                         string soundname;
00282                         if (psoundsArray->getArrayValue(soundname, i))
00283                         {
00284                                 soundname = CFile::getFilenameWithoutExtension(soundname);
00285                                 _Sounds.push_back(CStringMapper::map(soundname));
00286                         }
00287                 }
00288         }
00289 
00290 
00291         // Mode of the complex sound.
00292         string  mode;
00293         formRoot.getValueByName(mode, ".SoundType.Mode");
00294 
00295         if (mode == "Chained" || mode == "Sparse")
00296         {
00297                 // XFade lenght
00298                 formRoot.getValueByName(_XFadeLenght, ".SoundType.XFadeLenght");
00299                 // Fade in/out flag.
00300                 formRoot.getValueByName(_DoFadeIn, ".SoundType.DoFadeIn");
00301                 formRoot.getValueByName(_DoFadeOut, ".SoundType.DoFadeOut");
00302 
00303                 // convert xfade to millisec.
00304                 _XFadeLenght *= 1000;
00305                 _PatternMode = MODE_CHAINED;
00306                 // just read the sequence
00307                 _SoundSeq.clear();
00308 
00309                 string  str;
00310                 formRoot.getValueByName(str, ".SoundType.SoundSeq");
00311                 parseSequence(str, _SoundSeq);
00312 
00313                 if (mode == "Sparse")
00314                 {
00315                         _PatternMode = MODE_SPARSE;
00316                         // also read the delay sequence
00317                         _DelaySeq.clear();
00318 
00319                         string  str;
00320                         formRoot.getValueByName(str, ".SoundType.DelaySeq");
00321                         // parse the delay and premult by 1000 (for millisec).
00322                         parseSequence(str, _DelaySeq, 1000);
00323                 }
00324         }
00325         else if (mode == "AllInOne")
00326         {
00327                 _PatternMode = MODE_ALL_IN_ONE;
00328                 // nothing special to read.
00329         }
00330         else
00331                 nlassertex(false, ("Unsupported mode : %s", mode.c_str()));
00332         
00333 }

bool NLSOUND::CComplexSound::isDetailed  )  const [virtual]
 

Return true if cone is meaningful.

Implements NLSOUND::CSound.

Definition at line 15 of file complex_sound.cpp.

00016 {
00017         return false;
00018 }

bool NLSOUND::CSound::operator< const CSound otherSound  )  const [inline, inherited]
 

Definition at line 123 of file sound.h.

References NLSOUND::CSound::_Name, and NLMISC::CStringMapper::unmap().

00124         {
00125                 return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name);
00126         }

void NLSOUND::CComplexSound::parseSequence const std::string &  str,
std::vector< uint32 > &  seq,
uint  scale = 1
[private]
 

Definition at line 20 of file complex_sound.cpp.

References uint.

Referenced by importForm().

00021 {
00022         seq.clear();
00023 
00024         string  val;
00025         string::const_iterator first(str.begin()), last(str.end());
00026 
00027         for (; first != last; ++first)
00028         {
00029                 if (*first != ';')
00030                         val += *first;
00031                 else
00032                 {
00033                         seq.push_back(atoi(val.c_str()) * scale);
00034                         val.clear();
00035                 }
00036         }
00037 
00038         // parse the last value
00039         if (!val.empty())
00040                 seq.push_back(atoi(val.c_str()) * scale);
00041 
00042 }

void NLSOUND::CComplexSound::serial NLMISC::IStream s  )  [virtual]
 

Reimplemented from NLSOUND::CSound.

Definition at line 207 of file complex_sound.cpp.

References _DelaySeq, _DoFadeIn, _DoFadeOut, _PatternMode, _SoundSeq, _TicksPerSeconds, _XFadeLenght, s, uint, and uint32.

00208 {
00209         CSound::serial(s);
00210         s.serialEnum(_PatternMode);
00211         if (s.isReading())
00212         {
00213                 uint32 nb;
00214                 s.serial(nb);
00215 
00216                 for (uint i=0; i<nb; ++i)
00217                 {
00218                         std::string name;
00219                         s.serial(name);
00220                         _Sounds.push_back(CStringMapper::map(name));
00221                 }
00222         }
00223         else
00224         {
00225                 uint32 nb = _Sounds.size();
00226                 s.serial(nb);
00227                 for (uint i=0; i<nb; ++i)
00228                 {
00229                         std::string name = CStringMapper::unmap(_Sounds[i]);
00230                         s.serial(name);
00231                 }
00232         }
00233         s.serial(_TicksPerSeconds);
00234         s.serialCont(_SoundSeq);
00235         s.serialCont(_DelaySeq);
00236         s.serial(_XFadeLenght);
00237         s.serial(_DoFadeIn);
00238         s.serial(_DoFadeOut);
00239 
00240         if (s.isReading())
00241                 _DurationValid = false;
00242 }

void NLSOUND::CSound::setLooping bool  looping  )  [inline, inherited]
 

Set looping.

Definition at line 113 of file sound.h.

References NLSOUND::CSound::_Looping.

00113 { _Looping = looping; }

void NLSOUND::CComplexSound::setPatternMode TPATTERN_MODE  patternMode  )  [inline]
 

Definition at line 60 of file complex_sound.h.

References _PatternMode.

00060 { _PatternMode = patternMode;}

virtual void NLSOUND::CComplexSound::setTicksPerSecond float  ticks  )  [inline, virtual]
 

Definition at line 81 of file complex_sound.h.

References _TicksPerSeconds.

00081 { _TicksPerSeconds = ticks; }


Field Documentation

float NLSOUND::CSound::_ConeInnerAngle [protected, inherited]
 

Definition at line 134 of file sound.h.

Referenced by NLSOUND::CSound::getConeInnerAngle(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial().

float NLSOUND::CSound::_ConeOuterAngle [protected, inherited]
 

Definition at line 134 of file sound.h.

Referenced by NLSOUND::CSound::getConeOuterAngle(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial().

float NLSOUND::CSound::_ConeOuterGain [protected, inherited]
 

Definition at line 134 of file sound.h.

Referenced by NLSOUND::CSound::getConeOuterGain(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial().

std::vector<uint32> NLSOUND::CComplexSound::_DelaySeq [private]
 

Sequence of delay in millisec.

Definition at line 103 of file complex_sound.h.

Referenced by getDelaySeq(), getDuration(), importForm(), and serial().

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

Definition at line 135 of file sound.h.

bool NLSOUND::CComplexSound::_DoFadeIn [private]
 

Flag for fade in.

Definition at line 108 of file complex_sound.h.

Referenced by doFadeIn(), importForm(), and serial().

bool NLSOUND::CComplexSound::_DoFadeOut [private]
 

Flag for fade out (only on normal termination, not explicit stop).

Definition at line 110 of file complex_sound.h.

Referenced by doFadeOut(), importForm(), and serial().

uint32 NLSOUND::CComplexSound::_Duration [private]
 

Definition at line 115 of file complex_sound.h.

bool NLSOUND::CComplexSound::_DurationValid [private]
 

Definition at line 117 of file complex_sound.h.

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

Definition at line 131 of file sound.h.

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

Definition at line 137 of file sound.h.

Referenced by NLSOUND::CSound::getLooping(), NLSOUND::CSound::importForm(), NLSOUND::CSound::serial(), and NLSOUND::CSound::setLooping().

float NLSOUND::CSound::_MaxDist [protected, inherited]
 

Clipping distance for complex or backgound sound.

Definition at line 140 of file sound.h.

Referenced by getMaxDistance().

bool NLSOUND::CComplexSound::_MaxDistValid [mutable, private]
 

Definition at line 112 of file complex_sound.h.

Referenced by getMaxDistance().

NLMISC::TStringId NLSOUND::CSound::_Name [protected, inherited]
 

Definition at line 143 of file sound.h.

Referenced by NLSOUND::CSound::operator<().

TPATTERN_MODE NLSOUND::CComplexSound::_PatternMode [private]
 

Definition at line 98 of file complex_sound.h.

Referenced by getDuration(), getPatternMode(), importForm(), serial(), and setPatternMode().

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

Definition at line 132 of file sound.h.

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

Definition at line 133 of file sound.h.

Referenced by NLSOUND::CSound::getPriority(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial().

std::vector<NLMISC::TStringId> NLSOUND::CComplexSound::_Sounds [private]
 

Definition at line 99 of file complex_sound.h.

std::vector<uint32> NLSOUND::CComplexSound::_SoundSeq [private]
 

Definition at line 101 of file complex_sound.h.

Referenced by getDuration(), getSoundSeq(), importForm(), and serial().

float NLSOUND::CComplexSound::_TicksPerSeconds [private]
 

Definition at line 100 of file complex_sound.h.

Referenced by getDuration(), getTicksPerSecond(), importForm(), serial(), and setTicksPerSecond().

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

An optional user var controler.

Definition at line 145 of file sound.h.

Referenced by NLSOUND::CSound::getUserVarControler(), and NLSOUND::CAudioMixerUser::initUserVar().

uint32 NLSOUND::CComplexSound::_XFadeLenght [private]
 

Duration of xfade in millisec.

Definition at line 106 of file complex_sound.h.

Referenced by getDuration(), getFadeLenght(), importForm(), and serial().


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