#include <sound.h>
Inheritance diagram for NLSOUND::CSound:
Nevrax France
Definition at line 60 of file sound.h.
Public Types | |
enum | TSOUND_TYPE { SOUND_SIMPLE, SOUND_COMPLEX, SOUND_BACKGROUND, SOUND_CONTEXT } |
Public Member Functions | |
CSound () | |
Constructor. | |
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 NLMISC::CVector & | getDirectionVector () const |
Return the direction vector. | |
virtual uint32 | getDuration ()=0 |
Return the length of the sound in ms. | |
float | getGain () const |
Return the gain. | |
bool | getLooping () const |
Return the looping state. | |
virtual float | getMaxDistance () const |
Return the max distance (if detailed()). | |
const NLMISC::TStringId & | getName () const |
Return the name (must be unique). | |
float | getPitch () const |
Return the pitch. | |
TSoundPriority | getPriority () const |
Return the initial priority. | |
virtual TSOUND_TYPE | getSoundType ()=0 |
Get the type of the sound. | |
virtual void | getSubSoundList (std::vector< std::pair< std::string, CSound * > > &subsounds) const=0 |
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. | |
virtual bool | isDetailed () const=0 |
Return true if cone is meaningful. | |
bool | operator< (const CSound &otherSound) const |
virtual void | serial (NLMISC::IStream &s) |
void | setLooping (bool looping) |
Set looping. | |
virtual | ~CSound () |
Destructor. | |
Static Public Member Functions | |
CSound * | createSound (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. | |
Friends | |
class | CAudioMixerUser |
|
Definition at line 67 of file sound.h.
00068 { 00069 SOUND_SIMPLE, 00070 SOUND_COMPLEX, 00071 SOUND_BACKGROUND, 00072 SOUND_CONTEXT 00073 }; |
|
Constructor.
Definition at line 97 of file sound.cpp. References NLSOUND::MidPri.
00097 : 00098 _Gain(1.0f), 00099 _Pitch(1.0f), 00100 _MaxDist(1000000.0f), 00101 _Priority(MidPri), 00102 _Looping(false), 00103 _ConeInnerAngle(6.283185f), 00104 _ConeOuterAngle(6.283185f), 00105 _ConeOuterGain( 1.0f ), 00106 _UserVarControler(CStringMapper::emptyId()) 00107 { 00108 } |
|
Destructor.
Definition at line 110 of file sound.cpp.
00111 {} |
|
Factory for specialized sound.
Definition at line 43 of file sound.cpp. References NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), 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 } |
|
Return the inner angle of the cone.
Definition at line 98 of file sound.h. References _ConeInnerAngle. Referenced by NLSOUND::CSimpleSource::setDirection().
00098 { return _ConeInnerAngle; } |
|
Return the outer angle of the cone.
Definition at line 100 of file sound.h. References _ConeOuterAngle. Referenced by NLSOUND::CSimpleSource::setDirection().
00100 { return _ConeOuterAngle; } |
|
Return the outer gain of the cone.
Definition at line 102 of file sound.h. References _ConeOuterGain. Referenced by NLSOUND::CSimpleSource::setDirection().
00102 { return _ConeOuterGain; } |
|
Return the direction vector.
Definition at line 104 of file sound.h.
00104 { return _Direction;} |
|
Return the length of the sound in ms.
Implemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. Referenced by NLSOUND::CAmbiantSource::calcRandomSparseSoundTime(), NLSOUND::CComplexSound::getDuration(), NLSOUND::CBackgroundSound::getDuration(), NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::onUpdate(), and NLSOUND::CComplexSource::playStuf(). |
|
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; } |
|
Return the looping state.
Definition at line 88 of file sound.h. References _Looping. Referenced by NLSOUND::CComplexSource::CComplexSource(), and NLSOUND::CComplexSource::checkup().
00088 { return _Looping; } |
|
Return the max distance (if detailed()).
Reimplemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, and NLSOUND::CContextSound. Definition at line 110 of file sound.h. Referenced by NLSOUND::CContextSoundContainer< NbJoker, UseRandom, Shift >::addSound(), NLSOUND::CBackgroundSoundManager::addSound(), NLSOUND::CAudioMixerUser::getFreeTrack(), NLSOUND::CComplexSound::getMaxDistance(), NLSOUND::CBackgroundSound::getMaxDistance(), and NLSOUND::CSimpleSource::play().
00110 { return _MaxDist; } |
|
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; } |
|
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; } |
|
Return the initial priority.
Definition at line 94 of file sound.h. References _Priority, and NLSOUND::TSoundPriority. Referenced by NLSOUND::CComplexSource::CComplexSource().
00094 { return _Priority; } |
|
Get the type of the sound.
Implemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. Referenced by NLSOUND::CSoundSerializer::serial(). |
|
Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).
Implemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. |
|
Definition at line 121 of file sound.h. References _UserVarControler.
00121 { return _UserVarControler; } |
|
Load the sound parameters from georges' form. Load the sound parameters from georges' form Reimplemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. Definition at line 140 of file sound.cpp. References _ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain, _Looping, _Priority, NLGEORGES::UFormElm::getValueByName(), NLSOUND::HighestPri, NLSOUND::HighPri, NLSOUND::LowPri, NLSOUND::MidPri, NLMISC::Pi, sint32, NLSOUND::Sqrt12_2, uint32, x, y, and z. Referenced by createSound().
00141 { 00142 // Name 00143 _Name = CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); 00144 00145 // InternalConeAngle 00146 uint32 inner; 00147 root.getValueByName(inner, ".InternalConeAngle"); 00148 if (inner > 360) 00149 { 00150 inner = 360; 00151 } 00152 _ConeInnerAngle = (float) (Pi * inner / 180.0f); // convert to radians 00153 00154 // ExternalConeAngle 00155 uint32 outer; 00156 root.getValueByName(outer, ".ExternalConeAngle"); 00157 if (outer > 360) 00158 { 00159 outer = 360; 00160 } 00161 _ConeOuterAngle= (float) (Pi * outer / 180.0f); // convert to radians 00162 00163 // Loop 00164 root.getValueByName(_Looping, ".Loop"); 00165 00166 // Gain 00167 sint32 gain; 00168 root.getValueByName(gain, ".Gain"); 00169 if (gain > 0) 00170 { 00171 gain = 0; 00172 } 00173 if (gain < -100) 00174 { 00175 gain = -100; 00176 } 00177 _Gain = (float) pow(10.0, gain / 20.0); // convert dB to linear gain 00178 00179 // External gain 00180 root.getValueByName(gain, ".ExternalGain"); 00181 if (gain > 0) 00182 { 00183 gain = 0; 00184 } 00185 if (gain < -100) 00186 { 00187 gain = -100; 00188 } 00189 _ConeOuterGain = (float) pow(10.0, gain / 20.0); // convert dB to linear gain 00190 00191 // Direction 00192 float x, y, z; 00193 00194 root.getValueByName(x, ".Direction.X"); 00195 root.getValueByName(y, ".Direction.Y"); 00196 root.getValueByName(z, ".Direction.Z"); 00197 _Direction = CVector(x, y, z); 00198 00199 00200 // Pitch 00201 sint32 trans; 00202 root.getValueByName(trans, ".Transpose"); 00203 _Pitch = (float) pow(Sqrt12_2, trans); // convert semi-tones to playback speed 00204 00205 // Priority 00206 uint32 prio = 0; 00207 root.getValueByName(prio, ".Priority"); 00208 switch (prio) 00209 { 00210 case 0: 00211 _Priority = LowPri; 00212 break; 00213 case 1: 00214 _Priority = MidPri; 00215 break; 00216 case 2: 00217 _Priority = HighPri; 00218 break; 00219 case 3: 00220 _Priority = HighestPri; 00221 break; 00222 default: 00223 _Priority = MidPri; 00224 } 00225 } |
|
Return true if cone is meaningful.
Implemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. |
|
Definition at line 123 of file sound.h. References _Name, and NLMISC::CStringMapper::unmap().
00124 { 00125 return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); 00126 } |
|
Reimplemented in NLSOUND::CBackgroundSound, NLSOUND::CComplexSound, NLSOUND::CContextSound, and NLSOUND::CSimpleSound. Definition at line 114 of file sound.cpp. References _ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain, _Looping, _Priority, and s. Referenced by NLSOUND::CSoundSerializer::serial().
00115 { 00116 s.serial(_Gain); 00117 s.serial(_Pitch); 00118 s.serialEnum(_Priority); 00119 s.serial(_ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain); 00120 s.serial(_Direction); 00121 s.serial(_Looping); 00122 s.serial(_MaxDist); 00123 if (s.isReading()) 00124 { 00125 std::string name; 00126 s.serial(name); 00127 _Name = CStringMapper::map(name); 00128 } 00129 else 00130 { 00131 std::string name = CStringMapper::unmap(_Name); 00132 s.serial(name); 00133 } 00134 } |
|
Set looping.
Definition at line 113 of file sound.h. References _Looping.
00113 { _Looping = looping; } |
|
|
|
Definition at line 134 of file sound.h. Referenced by getConeInnerAngle(), importForm(), and serial(). |
|
Definition at line 134 of file sound.h. Referenced by getConeOuterAngle(), importForm(), and serial(). |
|
Definition at line 134 of file sound.h. Referenced by getConeOuterGain(), importForm(), and serial(). |
|
|
|
|
|
Definition at line 137 of file sound.h. Referenced by getLooping(), importForm(), serial(), and setLooping(). |
|
Clipping distance for complex or backgound sound.
Definition at line 140 of file sound.h. Referenced by NLSOUND::CComplexSound::getMaxDistance(). |
|
Definition at line 143 of file sound.h. Referenced by operator<(). |
|
|
|
Definition at line 133 of file sound.h. Referenced by getPriority(), importForm(), and serial(). |
|
An optional user var controler.
Definition at line 145 of file sound.h. Referenced by getUserVarControler(), and NLSOUND::CAudioMixerUser::initUserVar(). |