sound_anim_marker.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #include "stdsound.h"
00025 #include "nel/misc/common.h"
00026 #include "nel/misc/string_mapper.h"
00027 #include "nel/sound/sound_anim_marker.h"
00028 #include "nel/sound/u_audio_mixer.h"
00029 #include "nel/sound/u_source.h"
00030 
00031 using namespace std;
00032 using namespace NLSOUND;
00033 using namespace NLMISC;
00034 
00035 namespace NLSOUND {
00036 
00037 // ********************************************************
00038 
00039 CSoundAnimMarker::~CSoundAnimMarker()
00040 {
00041 }
00042 
00043 // ********************************************************
00044 
00045 void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundContext &context)
00046 {
00047     TMarkerSoundSet::iterator first(_Sounds.begin()), last(_Sounds.end());
00048 
00049     for (; first != last; ++first)
00050     {
00051         USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context);
00052         if (source != NULL)
00053         {
00054             source->setRelativeGain(context.RelativeGain);
00055             source->setPos(context.Position);
00056             source->play();
00057         }
00058     }
00059 }
00060 
00061 // ********************************************************
00062 
00063 void CSoundAnimMarker::addSound(const NLMISC::TStringId& soundName)
00064 {
00065     pair<TMarkerSoundSet::iterator, bool> inserted;
00066     inserted = _Sounds.insert(soundName);
00067     if (inserted.second == false)
00068     {
00069         nlwarning("Duplicate sound (%s)", CStringMapper::unmap(soundName).c_str());
00070     }
00071 }
00072 
00073 // ********************************************************
00074 
00075 void CSoundAnimMarker::removeSound(const NLMISC::TStringId &soundName)
00076 {
00077     TMarkerSoundSet::iterator iter = _Sounds.find(soundName);
00078     if (iter != _Sounds.end())
00079     {
00080         _Sounds.erase(iter);
00081     }
00082     else
00083     {
00084         nlwarning("No sound was removed (%s)", CStringMapper::unmap(soundName).c_str());
00085     }
00086 }
00087 
00088 // ********************************************************
00089 
00090 void CSoundAnimMarker::getSounds(vector<NLMISC::TStringId> &sounds)
00091 {
00092     sounds.insert(sounds.end(), _Sounds.begin(), _Sounds.end());
00093 
00094 /*  TMarkerSoundSet::iterator first(_Sounds.begin()), last(_Sounds.end());
00095     for (; first != last; ++first)
00096     {
00097         sounds.push_back((*first).c_str());
00098     }
00099 */
00100 }
00101 
00102 
00103 
00104 } // namespace NLSOUND

Generated on Thu Jan 7 08:26:38 2010 for NeL by  doxygen 1.6.1