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