complex_sound.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_COMPLEX_SOUND_H
00025 #define NL_COMPLEX_SOUND_H
00026 
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/misc/string_mapper.h"
00029 #include "sound.h"
00030 #include <string>
00031 
00032 namespace NLSOUND
00033 {
00034 
00035 class ISoundController;
00036 
00037 
00038 typedef std::basic_string<uint16>   uint16_string;
00039 
00040 
00041 class CComplexSound : public CSound
00042 {
00043 public:
00044 
00045     enum TPATTERN_MODE
00046     {
00047         MODE_UNDEFINED,
00048         MODE_CHAINED,
00049         MODE_ALL_IN_ONE,
00050         MODE_SPARSE
00051     };
00052 
00053     bool                            isDetailed() const;
00054     uint32                          getDuration();
00055 
00056 
00057     TPATTERN_MODE                   getPatternMode()                            { return _PatternMode;}
00058     void                            setPatternMode(TPATTERN_MODE patternMode)   { _PatternMode = patternMode;}
00059 
00060     const std::vector<uint32>       &getSoundSeq() const                        { return _SoundSeq;}
00061     const std::vector<uint32>       &getDelaySeq() const                        { return _DelaySeq;}
00062     NLMISC::TStringId               getSound(uint index) const                  { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]:0;}
00063     const std::vector<NLMISC::TStringId>    &getSounds() const                  { return _Sounds;}
00064 
00065     uint32                          getFadeLenght() const                       { return _XFadeLenght;}
00066 
00068     CComplexSound();
00069 
00071     virtual ~CComplexSound();
00072 
00074     virtual void                    importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot);
00075 
00077 
00078     virtual float                   getTicksPerSecond()                         { return _TicksPerSeconds; }
00079     virtual void                    setTicksPerSecond(float ticks)              { _TicksPerSeconds = ticks; }
00081 
00082     TSOUND_TYPE                     getSoundType() {return SOUND_COMPLEX;};
00083 
00084     void                            getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const;
00085     bool                            doFadeIn()                              { return _DoFadeIn; }
00086     bool                            doFadeOut()                             { return _DoFadeOut; }
00087 
00088     void                            serial(NLMISC::IStream &s);
00089 
00090 
00091 private:
00092 
00093     void                            parseSequence(const std::string &str, std::vector<uint32> &seq, uint scale = 1);
00094     virtual float                   getMaxDistance() const;
00095 
00096     TPATTERN_MODE                   _PatternMode;
00097     std::vector<NLMISC::TStringId>  _Sounds;
00098     float                           _TicksPerSeconds;
00099     std::vector<uint32>             _SoundSeq;
00101     std::vector<uint32>         _DelaySeq;
00102 
00104     uint32                      _XFadeLenght;
00106     bool                        _DoFadeIn;
00108     bool                        _DoFadeOut;
00109 
00110     mutable bool                _MaxDistValid;
00111 
00112     // Duration of sound.
00113     uint32                      _Duration;
00114     // flag for validity of duration (after first evaluation).
00115     bool                        _DurationValid;
00116 };
00117 
00118 } // namespace
00119 
00120 #endif // NL_COMPLEX_SOUND_H
00121 

Generated on Thu Jan 7 08:26:37 2010 for NeL by  doxygen 1.6.1