#include <simple_sound.h>
Inheritance diagram for NLSOUND::CSimpleSound:

Nevrax France
Definition at line 46 of file simple_sound.h.
Public Types | |
| enum | TSOUND_TYPE { SOUND_SIMPLE, SOUND_COMPLEX, SOUND_BACKGROUND, SOUND_CONTEXT } |
Public Member Functions | |
| CSimpleSound () | |
| Constructor. | |
| float | getAlpha () const |
| Return the alpha attenuation value. | |
| IBuffer * | getBuffer () |
| Return the buffer and the buffername if not null. | |
| const NLMISC::TStringId & | getBuffername () const |
| Return the name of the buffer (must be unique). | |
| 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. | |
| uint32 | getDuration () |
| Return the length of the sound in ms. | |
| const NLMISC::TStringId & | getFilename () const |
| Return the filename. | |
| float | getGain () const |
| Return the gain. | |
| bool | getLooping () const |
| Return the looping state. | |
| virtual float | getMaxDistance () const |
| Return the max distance (if detailed()). | |
| float | getMinDistance () const |
| Return the min 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. | |
| void | getSubSoundList (std::vector< std::pair< std::string, CSound * > > &subsounds) const |
| 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 distance and cone are meaningful. | |
| bool | operator< (const CSound &otherSound) const |
| void | serial (NLMISC::IStream &s) |
| void | setBuffer (IBuffer *buffer) |
| Change the buffer. | |
| void | setLooping (bool looping) |
| Set looping. | |
| virtual | ~CSimpleSound () |
| 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 Member Functions | |
| TSOUND_TYPE | getSoundType () |
| Get the type of the sound. | |
Private Attributes | |
| double | _Alpha |
| IBuffer * | _Buffer |
| NLMISC::TStringId | _Buffername |
| bool | _Detailed |
| NLMISC::TStringId | _Filename |
| float | _MinDist |
| bool | _NeedContext |
| bool | _Registered |
|
|
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 45 of file simple_sound.cpp.
00045 : 00046 _Buffer(NULL), 00047 _MinDist(1.0f), 00048 _Detailed(false), 00049 _Registered(false), 00050 _NeedContext(false) 00051 { 00052 } |
|
|
Destructor.
Definition at line 58 of file simple_sound.cpp.
00059 {
00060 if (_Buffer != NULL)
00061 CSoundBank::instance()->unregisterBufferAssoc(this, _Buffer);
00062 }
|
|
||||||||||||
|
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 alpha attenuation value.
Definition at line 69 of file simple_sound.h. Referenced by NLSOUND::CSimpleSource::CSimpleSource().
00069 { return float(_Alpha); }
|
|
|
Return the buffer and the buffername if not null.
Definition at line 93 of file simple_sound.cpp. References _Buffername, and _Registered. Referenced by NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CSimpleSource::getBuffer(), getDuration(), NLSOUND::CSimpleSource::play(), and NLSOUND::CSimpleSource::setDirection().
00094 {
00095 if (_Buffer == 0)
00096 {
00097 // try to find the sample buffer in the sample bank.
00098 _Buffer = CSampleBank::get(_Buffername);
00099 CSoundBank::instance()->registerBufferAssoc(this, _Buffer);
00100 _Registered = true;
00101 }
00102 return _Buffer;
00103 }
|
|
|
Return the name of the buffer (must be unique).
Definition at line 75 of file simple_sound.h. References _Buffername. Referenced by NLSOUND::CAudioMixerUser::createSource().
00075 { return _Buffername; }
|
|
|
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 109 of file simple_sound.cpp. References buffer, getBuffer(), and uint32. Referenced by NLSOUND::CSimpleSource::play().
|
|
|
Return the filename.
Definition at line 73 of file simple_sound.h.
00073 { return _Filename; }
|
|
|
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 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 min distance (if detailed()).
Definition at line 67 of file simple_sound.h. References _MinDist. Referenced by NLSOUND::CAudioMixerUser::getFreeTrack(), and NLSOUND::CSimpleSource::play().
00067 { return _MinDist; }
|
|
|
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; }
|
|
|
Get the type of the sound.
Implements NLSOUND::CSound. Definition at line 88 of file simple_sound.h.
00088 {return SOUND_SIMPLE;};
|
|
|
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 82 of file simple_sound.cpp. References _Buffername.
00083 {
00084 // A little hack, we use the reference vector to tag unavailable sample.
00085 if (!(_Buffername == CStringMapper::emptyId()) && const_cast<CSimpleSound*>(this)->getBuffer() == 0)
00086 subsounds.push_back(pair<string, CSound*>(CStringMapper::unmap(_Buffername)+" (sample)", 0));
00087 }
|
|
|
Definition at line 121 of file sound.h. References NLSOUND::CSound::_UserVarControler.
00121 { return _UserVarControler; }
|
|
||||||||||||
|
Load the sound parameters from georges' form. Allow to load sound files when corresponding wave file is missing (default: false, i.e. an input serial or a load throws an exception ESoundFileNotFound) Reimplemented from NLSOUND::CSound. Definition at line 155 of file simple_sound.cpp. References _Buffername, _MinDist, _NeedContext, NLGEORGES::UFormElm::getDfnName(), NLGEORGES::UFormElm::getNodeByName(), NLGEORGES::UFormElm::getValueByName(), nlassert, and setBuffer().
00156 {
00157 NLGEORGES::UFormElm *psoundType;
00158 std::string dfnName;
00159
00160 // some basic checking.
00161 root.getNodeByName(&psoundType, ".SoundType");
00162 nlassert(psoundType != NULL);
00163 psoundType->getDfnName(dfnName);
00164 nlassert(dfnName == "simple_sound.dfn");
00165
00166 // Call the base class
00167 CSound::importForm(filename, root);
00168
00169 // Name
00170 _Filename = CStringMapper::map(filename);
00171
00172 // Buffername
00173 std::string bufferName;
00174 root.getValueByName(bufferName, ".SoundType.Filename");
00175 bufferName = CFile::getFilenameWithoutExtension(bufferName);
00176 _Buffername = CStringMapper::map(bufferName);
00177
00178 setBuffer(NULL);
00179
00180 // contain % so it need a context to play
00181 if (bufferName.find ("%") != string::npos)
00182 {
00183 _NeedContext = true;
00184 }
00185
00186 // MaxDistance
00187 root.getValueByName(_MaxDist, ".SoundType.MaxDistance");
00188
00189 // MinDistance
00190 root.getValueByName(_MinDist, ".SoundType.MinDistance");
00191
00192 // Alpha
00193 root.getValueByName(_Alpha, ".SoundType.Alpha");
00194
00195 }
|
|
|
Return true if distance and cone are meaningful.
Implements NLSOUND::CSound. Definition at line 65 of file simple_sound.h. References _Detailed.
00065 { return _Detailed; }
|
|
|
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 124 of file simple_sound.cpp. References _Buffername, _MinDist, _NeedContext, s, and setBuffer().
00125 {
00126 std::string bufferName;
00127 CSound::serial(s);
00128
00129 s.serial(_MinDist);
00130 s.serial(_Alpha);
00131
00132 if (s.isReading())
00133 {
00134 s.serial(bufferName);
00135 _Buffername = CStringMapper::map(bufferName);
00136 setBuffer(NULL);
00137
00138 // contain % so it need a context to play
00139 if (bufferName.find ("%") != string::npos)
00140 {
00141 _NeedContext = true;
00142 }
00143 }
00144 else
00145 {
00146 bufferName = CStringMapper::unmap(_Buffername);
00147 s.serial(bufferName);
00148 }
00149 }
|
|
|
Change the buffer.
Definition at line 64 of file simple_sound.cpp. References _Registered, buffer, and NLSOUND::IBuffer::getName(). Referenced by NLSOUND::CSoundBank::bufferLoaded(), NLSOUND::CSoundBank::bufferUnloaded(), importForm(), and serial().
00065 {
00066 if (_Buffer != NULL && buffer != NULL && _Buffer->getName() != buffer->getName())
00067 {
00068 // if buffer name change, update the registration/
00069 CSoundBank::instance()->unregisterBufferAssoc(this, _Buffer);
00070 CSoundBank::instance()->registerBufferAssoc(this, buffer);
00071 }
00072 else if (!_Registered && buffer != NULL)
00073 {
00074 // creater initial registration.
00075 CSoundBank::instance()->registerBufferAssoc(this, buffer);
00076 _Registered = true;
00077 }
00078 _Buffer = buffer;
00079 }
|
|
|
Set looping.
Definition at line 113 of file sound.h. References NLSOUND::CSound::_Looping.
00113 { _Looping = looping; }
|
|
|
Definition at line 101 of file simple_sound.h. |
|
|
Definition at line 96 of file simple_sound.h. |
|
|
Definition at line 110 of file simple_sound.h. Referenced by getBuffer(), getBuffername(), getSubSoundList(), importForm(), and serial(). |
|
|
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 99 of file simple_sound.h. Referenced by isDetailed(). |
|
|
|
|
|
Definition at line 109 of file simple_sound.h. |
|
|
|
|
|
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 100 of file simple_sound.h. Referenced by getMinDistance(), importForm(), and serial(). |
|
|
Definition at line 143 of file sound.h. Referenced by NLSOUND::CSound::operator<(). |
|
|
Definition at line 104 of file simple_sound.h. Referenced by importForm(), and serial(). |
|
|
|
|
|
Definition at line 133 of file sound.h. Referenced by NLSOUND::CSound::getPriority(), NLSOUND::CSound::importForm(), and NLSOUND::CSound::serial(). |
|
|
Definition at line 93 of file simple_sound.h. Referenced by getBuffer(), and setBuffer(). |
|
|
An optional user var controler.
Definition at line 145 of file sound.h. Referenced by NLSOUND::CSound::getUserVarControler(), and NLSOUND::CAudioMixerUser::initUserVar(). |
1.3.6