#include <sound_anim_manager.h>
Definition at line 76 of file sound_anim_manager.h.
Public Member Functions | |
virtual TSoundAnimId | createAnimation (std::string &name) |
CSoundAnimManager (UAudioMixer *mixer) | |
virtual CSoundAnimation * | findAnimation (std::string &name) |
virtual TSoundAnimId | getAnimationFromName (std::string &name) |
virtual std::string | idToName (TSoundAnimId id) |
virtual bool | isPlaying (TSoundAnimPlayId playbackId) |
virtual TSoundAnimId | loadAnimation (std::string &name) |
virtual void | playAnimation (TSoundAnimId id, float lastTime, float curTime, NL3D::CCluster *cluster, CSoundContext &context) |
virtual TSoundAnimPlayId | playAnimation (std::string &name, float time, NL3D::CCluster *cluster, CSoundContext &context) |
virtual TSoundAnimPlayId | playAnimation (TSoundAnimId id, float time, NL3D::CCluster *cluster, CSoundContext &context) |
virtual void | saveAnimation (CSoundAnimation *anim, std::string &filname) |
virtual void | stopAnimation (TSoundAnimPlayId playbackId) |
virtual void | update (float lastTime, float curTime) |
virtual | ~CSoundAnimManager () |
Static Public Member Functions | |
CSoundAnimManager * | instance () |
void | release () |
Protected Attributes | |
TSoundAnimVector | _Animations |
TSoundAnimMap | _IdMap |
UAudioMixer * | _Mixer |
Static Protected Attributes | |
CSoundAnimManager * | _Instance = 0 |
|
Definition at line 44 of file sound_anim_manager.cpp.
|
|
Definition at line 57 of file sound_anim_manager.cpp.
00058 { 00059 if (_Instance == NULL) 00060 return; 00061 /* 00062 set<CSoundAnimPlayer*>::iterator iter; 00063 00064 for (iter = _Players.begin(); iter != _Players.end(); iter++) 00065 { 00066 CSoundAnimPlayer* player = *iter; 00067 delete player; 00068 } 00069 00070 _Players.clear(); 00071 */ 00072 00073 _Instance = NULL; 00074 } |
|
Create a new sound animation with the specified name. Returns CSoundAnimation::NoId if the creation fails (duplicate name).
Definition at line 120 of file sound_anim_manager.cpp. References NLSOUND::CSoundAnimationNoId, NLSOUND::CSoundAnimation::getName(), nlassert, nlwarning, and NLSOUND::TSoundAnimId. Referenced by loadAnimation().
00121 { 00122 NL_ALLOC_CONTEXT(NLSOUND_CSoundAnimManager); 00123 nlassert(!name.empty()); 00124 00125 // create and insert animations 00126 TSoundAnimId id = _Animations.size(); 00127 CSoundAnimation* anim = new CSoundAnimation(name, id); 00128 _Animations.push_back(anim); 00129 00130 // insert the name and id in the id table 00131 pair<TSoundAnimMap::iterator, bool> inserted; 00132 inserted =_IdMap.insert(make_pair(anim->getName().c_str(), id)); 00133 if (!inserted.second) 00134 { 00135 nlwarning("Duplicate sound animation \"%s\"", name.c_str()); 00136 delete anim; 00137 return CSoundAnimationNoId; 00138 } 00139 00140 return id; 00141 } |
|
Returns the animation corresponding to a name.
Definition at line 145 of file sound_anim_manager.cpp.
00146 { 00147 TSoundAnimMap::iterator iter = _IdMap.find(name.c_str()); 00148 return (iter == _IdMap.end())? 0 : _Animations[(*iter).second]; 00149 } |
|
Start playing a sound animation. Returns true is the animation was found and is playing.
Definition at line 153 of file sound_anim_manager.cpp. References NLSOUND::CSoundAnimationNoId, and NLSOUND::TSoundAnimId.
00154 { 00155 TSoundAnimMap::iterator iter = _IdMap.find(name.c_str()); 00156 return (iter == _IdMap.end())? CSoundAnimationNoId : (*iter).second; 00157 } |
|
Convert back from an anim ID to the anim name. Definition at line 206 of file sound_anim_manager.cpp. References NLSOUND::TSoundAnimId.
|
|
Definition at line 80 of file sound_anim_manager.h.
00080 { return _Instance; } |
|
Returns true is the animation with the specified playback ID is playing
Definition at line 273 of file sound_anim_manager.cpp. References NLSOUND::TSoundAnimPlayId.
00274 { 00275 /*nlassert(playbackId >= 0); 00276 00277 set<CSoundAnimPlayer*>::iterator iter; 00278 00279 for (iter = _Players.begin(); iter != _Players.end(); ) 00280 { 00281 CSoundAnimPlayer* player = *iter; 00282 if (player->getId() == playbackId) 00283 { 00284 return player->isPlaying(); 00285 } 00286 }*/ 00287 00288 return false; 00289 } |
|
Load the sound animation with the specified name. Returns the id of the new animation, or CSoundAnimationNoId is the file could not be found.
Definition at line 78 of file sound_anim_manager.cpp. References createAnimation(), NLSOUND::CSoundAnimationNoId, NLSOUND::CSoundAnimation::load(), nlassert, NLSOUND::CSoundAnimation::setFilename(), and NLSOUND::TSoundAnimId.
00079 { 00080 nlassert(!name.empty()); 00081 00082 string filename; 00083 if (name.find(".anim") != name.npos) 00084 { 00085 filename = CFile::getFilenameWithoutExtension(name); 00086 filename.append(".sound_anim"); 00087 } 00088 else 00089 { 00090 filename = name; 00091 filename.append(".sound_anim"); 00092 } 00093 00094 // throws exception if file not found 00095 filename = CPath::lookup(filename, false, false, true); 00096 if (filename.empty()) 00097 { 00098 return CSoundAnimationNoId; 00099 } 00100 00101 TSoundAnimId id = createAnimation(name); 00102 if (id == CSoundAnimationNoId) 00103 { 00104 return CSoundAnimationNoId; 00105 } 00106 00107 CSoundAnimation* anim = _Animations[id]; 00108 00109 if (anim == NULL) 00110 return CSoundAnimationNoId; 00111 00112 anim->setFilename(filename); 00113 anim->load(); 00114 00115 return id; 00116 } |
|
Play all the events of an animation in the interval between lastTime and curTime. Both lastTime and curTime are measured relatively from the beginning of the animation. Definition at line 218 of file sound_anim_manager.cpp. References _Mixer, NLSOUND::CSoundAnimationNoId, nlassert, NLSOUND::CSoundAnimation::play(), NLSOUND::TSoundAnimId, and uint32.
00219 { 00220 //nlassert(id != CSoundAnimationNoId); 00221 if (id == CSoundAnimationNoId) 00222 { 00223 return; 00224 } 00225 00226 if ((uint32) id >= _Animations.size()) 00227 return; 00228 nlassert((uint32) id < _Animations.size()); 00229 00230 CSoundAnimation* anim = _Animations[id]; 00231 nlassert(anim); 00232 00233 anim->play(_Mixer, lastTime, curTime, cluster, context); 00234 } |
|
Start playing a sound animation. Returns an id number of this playback instance or -1 if the animation was not found.
Definition at line 244 of file sound_anim_manager.cpp. References NLSOUND::TSoundAnimPlayId.
00245 { 00246 /* nlassert(position); 00247 00248 TSoundAnimId id = getAnimationFromName(name); 00249 return (id == CSoundAnimation::NoId)? -1 : _PlayerId;*/ 00250 return 0; 00251 } |
|
Start playing a sound animation. Returns an id number of this playback instance or -1 if the animation was not found.
Definition at line 238 of file sound_anim_manager.cpp. References NLSOUND::TSoundAnimId, and NLSOUND::TSoundAnimPlayId.
00239 {
00240 return 0;
00241 }
|
|
Definition at line 81 of file sound_anim_manager.h.
00081 { delete _Instance; } |
|
Save the sound animation in the specified file.
Definition at line 161 of file sound_anim_manager.cpp. References nlassert, NLSOUND::CSoundAnimation::save(), and NLSOUND::CSoundAnimation::setFilename().
00162 { 00163 nlassert(anim); 00164 nlassert(!filename.empty()); 00165 00166 anim->setFilename(filename); 00167 anim->save (); 00168 } |
|
Stop the playing of a sound animation.
Definition at line 255 of file sound_anim_manager.cpp. References NLSOUND::TSoundAnimPlayId.
00256 { 00257 /* nlassert(playbackId >= 0); 00258 00259 set<CSoundAnimPlayer*>::iterator iter; 00260 00261 for (iter = _Players.begin(); iter != _Players.end(); ) 00262 { 00263 CSoundAnimPlayer* player = *iter; 00264 if (player->getId() == playbackId) 00265 { 00266 _Players.erase(iter); 00267 break; 00268 } 00269 }*/ 00270 } |
|
Update all the sound animations during playback. Definition at line 292 of file sound_anim_manager.cpp.
00293 { 00294 /* set<CSoundAnimPlayer*>::iterator iter; 00295 00296 _Garbage.clear(); 00297 00298 for (iter = _Players.begin(); iter != _Players.end(); iter++) 00299 { 00300 CSoundAnimPlayer* player = *iter; 00301 if (player->isPlaying()) 00302 { 00303 player->update(lastTime, curTime); 00304 } 00305 else 00306 { 00307 _Garbage.push_back(player); 00308 } 00309 } 00310 00311 vector<CSoundAnimPlayer*>::iterator iter2; 00312 00313 for (iter2 = _Garbage.begin(); iter2 != _Garbage.end(); iter2++) 00314 { 00315 iter = _Players.find(*iter2); 00316 if (iter != _Players.end()) 00317 { 00318 _Players.erase(iter); 00319 } 00320 }*/ 00321 } |
|
The vector of all defined animations Definition at line 163 of file sound_anim_manager.h. |
|
The conversion table from animation name to id Definition at line 160 of file sound_anim_manager.h. |
|
The one and only singleton instance Definition at line 40 of file sound_anim_manager.cpp. |
|
The mixer Definition at line 157 of file sound_anim_manager.h. Referenced by playAnimation(). |