sound.h
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_SOUND_H
00025 #define NL_SOUND_H
00026
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/misc/stream.h"
00029 #include "nel/misc/string_mapper.h"
00030 #include "nel/sound/u_source.h"
00031 #include "nel/georges/u_form_elm.h"
00032 #include <string>
00033
00034 namespace NLSOUND {
00035
00036
00037 class ISoundDriver;
00038 class IBuffer;
00039 class CSound;
00040
00041
00043
00044 typedef CHashMap<NLMISC::TStringId, CSound*, NLMISC::CStringIdHashMapTraits> TSoundMap;
00045
00047 typedef std::set<CSound*> TSoundSet;
00048
00049 const double Sqrt12_2 = 1.0594630943592952645618252949463;
00050
00057 class CSound
00058 {
00059 friend class CAudioMixerUser;
00060 public:
00062 static CSound *createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot);
00063
00064 enum TSOUND_TYPE
00065 {
00066 SOUND_SIMPLE,
00067 SOUND_COMPLEX,
00068 SOUND_BACKGROUND,
00069 SOUND_CONTEXT,
00070 SOUND_MUSIC
00071 };
00072
00073
00075 CSound();
00077 virtual ~CSound();
00078
00080 virtual TSOUND_TYPE getSoundType() =0;
00081
00083 virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot);
00084
00086 bool getLooping() const { return _Looping; }
00088 float getGain() const { return _Gain; }
00090 float getPitch() const { return _Pitch; }
00092 TSoundPriority getPriority() const { return _Priority; }
00094 virtual bool isDetailed() const = 0;
00096 float getConeInnerAngle() const { return _ConeInnerAngle; }
00098 float getConeOuterAngle() const { return _ConeOuterAngle; }
00100 float getConeOuterGain() const { return _ConeOuterGain; }
00102 const NLMISC::CVector &getDirectionVector()const { return _Direction;}
00104 virtual uint32 getDuration() = 0;
00106 const NLMISC::TStringId& getName() const { return _Name; }
00108 virtual float getMaxDistance() const { return _MaxDist; }
00109
00111 void setLooping( bool looping ) { _Looping = looping; }
00112
00114 virtual void getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const =0;
00115
00116
00117 virtual void serial(NLMISC::IStream &s);
00118
00119 NLMISC::TStringId getUserVarControler() { return _UserVarControler; }
00120
00121 bool operator<( const CSound& otherSound ) const
00122 {
00123 return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name);
00124 }
00125
00126 protected:
00127
00128
00129 float _Gain;
00130 float _Pitch;
00131 TSoundPriority _Priority;
00132 float _ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain;
00133 NLMISC::CVector _Direction;
00134
00135 bool _Looping;
00136
00138 float _MaxDist;
00139
00140
00141 NLMISC::TStringId _Name;
00143 NLMISC::TStringId _UserVarControler;
00144
00145 };
00146
00147
00151 class ESoundFileNotFound : public NLMISC::Exception
00152 {
00153 public:
00154 ESoundFileNotFound( const std::string filename ) :
00155 NLMISC::Exception( (std::string("Sound file not found, or invalid file format: ")+filename).c_str() ) {}
00156 };
00157
00158
00159 }
00160
00161
00162 #endif // NL_SOUND_H
00163
00164
00165