00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_SOUND_H
00027 #define NL_SOUND_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/stream.h"
00031 #include "nel/sound/u_source.h"
00032 #include "nel/georges/u_form_elm.h"
00033 #include <string>
00034 #include <hash_map>
00035
00036 namespace NLSOUND {
00037
00038
00039 class ISoundDriver;
00040 class IBuffer;
00041 class CSound;
00042
00043
00045 typedef std::hash_map<std::string, CSound*> TSoundMap;
00046
00048 typedef std::set<CSound*> TSoundSet;
00049
00050 const double Sqrt12_2 = 1.0594630943592952645618252949463;
00051
00058 class CSound
00059 {
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 };
00071
00072
00074 CSound();
00076 virtual ~CSound();
00077
00079 virtual TSOUND_TYPE getSoundType() =0;
00080
00082 virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot);
00083
00085 bool getLooping() const { return _Looping; }
00087 float getGain() const { return _Gain; }
00089 float getPitch() const { return _Pitch; }
00091 TSoundPriority getPriority() const { return _Priority; }
00093 virtual bool isDetailed() const = 0;
00095 float getConeInnerAngle() const { return _ConeInnerAngle; }
00097 float getConeOuterAngle() const { return _ConeOuterAngle; }
00099 float getConeOuterGain() const { return _ConeOuterGain; }
00101 const NLMISC::CVector &getDirectionVector()const { return _Direction;}
00103 virtual uint32 getDuration() = 0;
00105 const std::string& getName() const { return _Name; }
00107 virtual float getMaxDistance() const { return _MaxDist; }
00108
00110 void setLooping( bool looping ) { _Looping = looping; }
00111
00113 virtual void getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const =0;
00114
00115
00116 virtual void serial(NLMISC::IStream &s);
00117
00118 bool operator<( const CSound& otherSound ) const
00119 {
00120 return _Name < otherSound._Name;
00121 }
00122
00123 protected:
00124
00125
00126 float _Gain;
00127 float _Pitch;
00128 TSoundPriority _Priority;
00129 float _ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain;
00130 NLMISC::CVector _Direction;
00131
00132 bool _Looping;
00133
00135 float _MaxDist;
00136
00137
00138 std::string _Name;
00139
00140 };
00141
00142
00146 class ESoundFileNotFound : public NLMISC::Exception
00147 {
00148 public:
00149 ESoundFileNotFound( const std::string filename ) :
00150 NLMISC::Exception( (std::string("Sound file not found, or invalid file format: ")+filename).c_str() ) {}
00151 };
00152
00153
00154 }
00155
00156
00157 #endif // NL_SOUND_H
00158
00159
00160