#include <background_sound.h>
Inheritance diagram for NLSOUND::CBackgroundSound:
Nevrax France
Definition at line 46 of file background_sound.h.
Public Types | |
enum | TSOUND_TYPE { SOUND_SIMPLE, SOUND_COMPLEX, SOUND_BACKGROUND, SOUND_CONTEXT } |
Public Member Functions | |
CBackgroundSound () | |
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 () |
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. | |
const std::vector< TSoundInfo > & | getSounds () const |
TSOUND_TYPE | getSoundType () |
Get the type of the sound. | |
virtual void | getSubSoundList (std::vector< std::pair< std::string, CSound * > > &subsounds) const |
Return the name (must be unique) 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. | |
bool | isDetailed () const |
Return true if cone is meaningful. | |
bool | operator< (const CSound &otherSound) const |
void | serial (NLMISC::IStream &s) |
void | setLooping (bool looping) |
Set looping. | |
~CBackgroundSound () | |
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. | |
Private Attributes | |
uint32 | _Duration |
bool | _DurationValid |
std::vector< TSoundInfo > | _Sounds |
The list of sound composing the background sound with there repective filter. |
|
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 43 of file background_sound.cpp.
00044 : _Duration(0), _DurationValid(false) 00045 { 00046 } |
|
Destructor.
Definition at line 48 of file background_sound.cpp.
00049 { 00050 } |
|
Factory for specialized sound.
Definition at line 43 of file sound.cpp. References NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), NLSOUND::CSound::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 NLSOUND::CSound::_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 NLSOUND::CSound::_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 NLSOUND::CSound::_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.
Implements NLSOUND::CSound. Definition at line 121 of file background_sound.cpp. References _Duration, _DurationValid, NLSOUND::CSound::getDuration(), NLSOUND::CAudioMixerUser::getSoundId(), and uint32.
00122 { 00123 if (_DurationValid) 00124 return _Duration; 00125 00126 vector<sint32> durations; 00127 CAudioMixerUser *mixer = CAudioMixerUser::instance(); 00128 std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); 00129 for (; first != last; ++first) 00130 { 00131 CSound *sound = mixer->getSoundId(first->SoundName); 00132 if (sound != NULL) 00133 durations.push_back(sound->getDuration()); 00134 } 00135 if (durations.empty()) 00136 return 0; 00137 _Duration = *(std::max_element(durations.begin(), durations.end())); 00138 _DurationValid = true; 00139 00140 return _Duration; 00141 } |
|
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 NLSOUND::CSound::_Looping. Referenced by NLSOUND::CComplexSource::CComplexSource(), and NLSOUND::CComplexSource::checkup().
00088 { return _Looping; } |
|
Return the max distance (if detailed()).
Reimplemented from NLSOUND::CSound. Definition at line 154 of file background_sound.cpp. References NLSOUND::CSound::getMaxDistance(), and NLSOUND::CAudioMixerUser::getSoundId().
00155 { 00156 CAudioMixerUser *mixer = CAudioMixerUser::instance(); 00157 float ret = 0.0f; 00158 std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); 00159 for (; first != last; ++first) 00160 { 00161 CSound *sound = mixer->getSoundId(first->SoundName); 00162 if (sound != 0) 00163 { 00164 ret = max(ret, sound->getMaxDistance()); 00165 } 00166 } 00167 if (ret == 0) 00168 ret = 1; 00169 00170 return ret; 00171 } |
|
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 NLSOUND::CSound::_Priority, and NLSOUND::TSoundPriority. Referenced by NLSOUND::CComplexSource::CComplexSource().
00094 { return _Priority; } |
|
Definition at line 95 of file background_sound.h. Referenced by NLSOUND::CBackgroundSource::play().
00095 { return _Sounds;} |
|
Get the type of the sound.
Implements NLSOUND::CSound. Definition at line 54 of file background_sound.h.
00054 { return SOUND_BACKGROUND;} |
|
Return the name (must be unique) Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).
Implements NLSOUND::CSound. Definition at line 143 of file background_sound.cpp. References NLSOUND::CAudioMixerUser::getSoundId().
00144 { 00145 CAudioMixerUser *mixer = CAudioMixerUser::instance(); 00146 std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); 00147 for (; first != last; ++first) 00148 { 00149 CSound *sound = mixer->getSoundId(first->SoundName); 00150 subsounds.push_back(make_pair(CStringMapper::unmap(first->SoundName), sound)); 00151 } 00152 } |
|
Definition at line 121 of file sound.h. References NLSOUND::CSound::_UserVarControler.
00121 { return _UserVarControler; } |
|
Load the sound parameters from georges' form.
Reimplemented from NLSOUND::CSound. Definition at line 62 of file background_sound.cpp. References _DurationValid, NLSOUND::CBackgroundSound::TSoundInfo::Filter, NLSOUND::UAudioMixer::TBackgroundFlags::Flags, NLGEORGES::UFormElm::getArrayNode(), NLGEORGES::UFormElm::getArraySize(), NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), NLGEORGES::UFormElm::getValueByName(), NLGEORGES::UFormElm::isArray(), nlassert, size, NLSOUND::CBackgroundSound::TSoundInfo::SoundName, and uint.
00063 { 00064 NLGEORGES::UFormElm *psoundType; 00065 std::string dfnName; 00066 00067 // some basic checking. 00068 formRoot.getNodeByName(&psoundType, ".SoundType"); 00069 nlassert(psoundType != NULL); 00070 psoundType->getDfnName(dfnName); 00071 nlassert(dfnName == "background_sound.dfn"); 00072 00073 // Call the base class 00074 CSound::importForm(filename, formRoot); 00075 00076 // Read the array of sound with there respective filter. 00077 { 00078 _Sounds.clear(); 00079 00080 NLGEORGES::UFormElm *psoundList; 00081 00082 formRoot.getNodeByName(&psoundList, ".SoundType.Sounds"); 00083 00084 if (psoundList != 0 && psoundList->isArray()) 00085 { 00086 uint size; 00087 psoundList->getArraySize(size); 00088 00089 for (uint i=0; i<size; ++i) 00090 { 00091 TSoundInfo sound; 00092 NLGEORGES::UFormElm *psoundItem; 00093 00094 psoundList->getArrayNode(&psoundItem, i); 00095 00096 if (psoundItem != NULL) 00097 { 00098 // Read the sound name. 00099 std::string soundName; 00100 psoundItem->getValueByName(soundName, "Sound"); 00101 sound.SoundName = CStringMapper::map(CFile::getFilenameWithoutExtension(soundName)); 00102 00103 00104 // Read the environnement flag. 00105 for (uint j=0; j<UAudioMixer::TBackgroundFlags::NB_BACKGROUND_FLAGS; j++) 00106 { 00107 char tmp[200]; 00108 sprintf(tmp, "Filter%2.2u", j); 00109 psoundItem->getValueByName(sound.Filter.Flags[j], tmp); 00110 } 00111 } 00112 00113 _Sounds.push_back(sound); 00114 } 00115 } 00116 } 00117 00118 _DurationValid = false; 00119 } |
|
Return true if cone is meaningful.
Implements NLSOUND::CSound. Definition at line 60 of file background_sound.h.
00060 { return false;} |
|
Definition at line 123 of file sound.h. References NLSOUND::CSound::_Name, and NLMISC::CStringMapper::unmap().
00124 { 00125 return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); 00126 } |
|
Reimplemented from NLSOUND::CSound. Definition at line 52 of file background_sound.cpp. References _DurationValid, and s.
00053 { 00054 CSound::serial(s); 00055 00056 s.serialCont(_Sounds); 00057 00058 if (s.isReading()) 00059 _DurationValid = false; 00060 } |
|
Set looping.
Definition at line 113 of file sound.h. References NLSOUND::CSound::_Looping.
00113 { _Looping = looping; } |
|
Definition at line 134 of file sound.h. Referenced by NLSOUND::CSound::getConeInnerAngle(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial(). |
|
Definition at line 134 of file sound.h. Referenced by NLSOUND::CSound::getConeOuterAngle(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial(). |
|
Definition at line 134 of file sound.h. Referenced by NLSOUND::CSound::getConeOuterGain(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial(). |
|
|
|
Definition at line 105 of file background_sound.h. Referenced by getDuration(). |
|
Definition at line 107 of file background_sound.h. Referenced by getDuration(), importForm(), and serial(). |
|
|
|
Definition at line 137 of file sound.h. Referenced by NLSOUND::CSound::getLooping(), NLSOUND::CSound::importForm(), NLSOUND::CSound::serial(), and NLSOUND::CSound::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 NLSOUND::CSound::operator<(). |
|
|
|
Definition at line 133 of file sound.h. Referenced by NLSOUND::CSound::getPriority(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial(). |
|
The list of sound composing the background sound with there repective filter.
Definition at line 101 of file background_sound.h. |
|
An optional user var controler.
Definition at line 145 of file sound.h. Referenced by NLSOUND::CSound::getUserVarControler(), and NLSOUND::CAudioMixerUser::initUserVar(). |