sound_anim_marker.cpp
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00095
00096
00097
00098
00099
00100 }
00101
00102
00103
00104 }