File: soundmanager.cpp

package info (click to toggle)
fife 0.4.2-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,312 kB
  • sloc: cpp: 42,647; xml: 18,881; python: 13,521; makefile: 24
file content (648 lines) | stat: -rw-r--r-- 19,183 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/***************************************************************************
 *   Copyright (C) 2005-2019 by the FIFE team                              *
 *   http://www.fifengine.net                                              *
 *   This file is part of FIFE.                                            *
 *                                                                         *
 *   FIFE is free software; you can redistribute it and/or                 *
 *   modify it under the terms of the GNU Lesser General Public            *
 *   License as published by the Free Software Foundation; either          *
 *   version 2.1 of the License, or (at your option) any later version.    *
 *                                                                         *
 *   This library is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   Lesser General Public License for more details.                       *
 *                                                                         *
 *   You should have received a copy of the GNU Lesser General Public      *
 *   License along with this library; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
 ***************************************************************************/

// Standard C++ library includes

// Platform specific includes

// 3rd party library includes

// FIFE includes
// These includes are split up in two parts, separated by one empty line
// First block: files included from the FIFE root src directory
// Second block: files included from the same folder
#include "audio/effects/soundeffectmanager.h"
#include "vfs/vfs.h"
#include "util/log/logger.h"
#include "util/base/exception.h"

#include "soundclipmanager.h"
#include "soundemitter.h"
#include "soundmanager.h"

namespace FIFE {
	/** Logger to use for this source file.
	 *  @relates Logger
	 */
	static Logger _log(LM_AUDIO);

	SoundManager::SoundManager() :
		m_context(0),
		m_device(0),
		m_muteVol(0),
		m_volume(1.0),
		m_maxDistance(50.0),
		m_distanceModel(SD_DISTANCE_INVERSE_CLAMPED),
		m_state(SM_STATE_INACTIV),
		m_sources(),
		m_createdSources(0),
		m_effectManager(NULL) {
	}

	SoundManager::~SoundManager() {
		// delete all soundemitters
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end();  ++it) {
			if ((*it) != NULL) {
				delete (*it);
			}
		}
		m_emitterVec.clear();
		// delete all sources
		alDeleteSources(m_createdSources, m_sources);
		// delete effect manager
		delete m_effectManager;

		if (m_device) {
			alcDestroyContext(m_context);
			alcCloseDevice(m_device);
			m_device = NULL;
		}

		if (alcGetError(NULL) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "error closing openal device");
		}
	}

	void SoundManager::init() {
		m_device = alcOpenDevice(NULL);

		if (!m_device || alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Could not open audio device - deactivating audio module");
			m_device = NULL;
			return;
		}

		m_context = alcCreateContext(m_device, NULL);
		if (!m_context || alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Couldn't create audio context - deactivating audio module");
			m_device = NULL;
			return;
		}

		alcMakeContextCurrent(m_context);
		if (alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Couldn't change current audio context - deactivating audio module");
			m_device = NULL;
			return;
		}
		// create and initialize the effect manager
		m_effectManager = new SoundEffectManager();
		m_effectManager->init(m_device);

		// set listener position
		alListener3f(AL_POSITION, 0.0, 0.0, 0.0);
		ALfloat vec1[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
		alListenerfv(AL_ORIENTATION, vec1);

		// set volume
		alListenerf(AL_GAIN, m_volume);

		// create max sources
		for (uint16_t i = 0; i < MAX_SOURCES; i++) {
			alGenSources(1, &m_sources[i]);
			if (alGetError() != AL_NO_ERROR) {
				break;
			}
			
			m_freeSources.push(m_sources[i]);
			m_createdSources++;
		}
		m_state = SM_STATE_PLAY;
	}

	bool SoundManager::isActive() const {
		return m_state != SM_STATE_INACTIV;
	}

	ALCcontext* SoundManager::getContext() const {
		return m_context;
	}

	void SoundManager::setVolume(float vol) {
		m_volume = vol;
		m_muteVol = vol;
		if (isActive()) {
			alListenerf(AL_GAIN, vol);
		}
	}

	float SoundManager::getVolume() const {
		return m_volume;
	}

	void SoundManager::mute() {
		if (isActive()) {
			alGetListenerf(AL_GAIN, &m_muteVol);
			alListenerf(AL_GAIN, 0);
		}
	}

	void SoundManager::unmute() {
		if (isActive()) {
			alListenerf(AL_GAIN, m_muteVol);
		}
	}

	void SoundManager::play() {
		m_state = SM_STATE_PLAY;
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end(); ++it) {
			SoundEmitter* emitter = (*it);
			if (!emitter) {
				continue;
			}
			emitter->play();
		}
	}

	void SoundManager::pause() {
		m_state = SM_STATE_PAUSE;
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end(); ++it) {
			SoundEmitter* emitter = (*it);
			if (!emitter) {
				continue;
			}
			emitter->pause();
		}
	}

	void SoundManager::stop() {
		m_state = SM_STATE_STOP;
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end(); ++it) {
			SoundEmitter* emitter = (*it);
			if (!emitter) {
				continue;
			}
			emitter->stop();
		}
	}

	void SoundManager::rewind() {
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end(); ++it) {
			SoundEmitter* emitter = (*it);
			if (!emitter) {
				continue;
			}
			emitter->rewind();
		}
	}

	void SoundManager::setDistanceModel(SoundDistanceModelType model) {
		m_distanceModel = model;
		if (!isActive()) {
			return;
		}

		switch (m_distanceModel) {
		case SD_DISTANCE_NONE:
			alDistanceModel(AL_NONE);
			break;
		case SD_DISTANCE_INVERSE:
			alDistanceModel(AL_INVERSE_DISTANCE);
			break;
		case SD_DISTANCE_INVERSE_CLAMPED:
			alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
			break;
		case SD_DISTANCE_LINEAR:
			alDistanceModel(AL_LINEAR_DISTANCE);
			break;
		case SD_DISTANCE_LINEAR_CLAMPED:
			alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
			break;
		case SD_DISTANCE_EXPONENT:
			alDistanceModel(AL_EXPONENT_DISTANCE);
			break;
		case SD_DISTANCE_EXPONENT_CLAMPED:
			alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
			break;
		default:
			break;
		}
	}

	SoundDistanceModelType SoundManager::getDistanceModel() const {
		return m_distanceModel;
	}

	void SoundManager::setListenerPosition(const AudioSpaceCoordinate& position) {
		if (isActive()) {
			alListener3f(AL_POSITION, static_cast<ALfloat>(position.x), static_cast<ALfloat>(position.y), static_cast<ALfloat>(position.z));
		}
	}

	AudioSpaceCoordinate SoundManager::getListenerPosition() const {
		if (isActive()) {
			ALfloat vec[3];
			alGetListenerfv(AL_POSITION, vec);
			return AudioSpaceCoordinate(vec[0], vec[1], vec[2]);
		}
		return AudioSpaceCoordinate();
	}

	void SoundManager::setListenerOrientation(const AudioSpaceCoordinate& orientation) {
		if (isActive()) {
			ALfloat vec[6] = { static_cast<ALfloat>(orientation.x), static_cast<ALfloat>(orientation.y), static_cast<ALfloat>(orientation.z),
				0.0, 0.0, 1.0 };
			alListenerfv(AL_ORIENTATION, vec);
		}
	}

	AudioSpaceCoordinate SoundManager::getListenerOrientation() const {
		if (isActive()) {
			ALfloat vec[6];
			alGetListenerfv(AL_ORIENTATION, vec);
			return AudioSpaceCoordinate(vec[0], vec[1], vec[2]);
		}
		return AudioSpaceCoordinate();
	}

	void SoundManager::setListenerVelocity(const AudioSpaceCoordinate& velocity) {
		if (isActive()) {
			alListener3f(AL_VELOCITY, static_cast<ALfloat>(velocity.x), static_cast<ALfloat>(velocity.y), static_cast<ALfloat>(velocity.z));
		}
	}

	AudioSpaceCoordinate SoundManager::getListenerVelocity() const {
		if (isActive()) {
			ALfloat vec[3];
			alGetListenerfv(AL_VELOCITY, vec);
			return AudioSpaceCoordinate(vec[0], vec[1], vec[2]);
		}
		return AudioSpaceCoordinate();
	}

	void SoundManager::setDopplerFactor(float factor) {
		if (isActive()) {
			if (factor >= 0.0) {
				alDopplerFactor(factor);
			}
		}
	}

	float SoundManager::getDopplerFactor() const {
		if (isActive()) {
			return alGetFloat(AL_DOPPLER_FACTOR);
		}
		return 0.0;
	}

	void SoundManager::setListenerMaxDistance(float distance) {
		m_maxDistance = distance;
	}

	float SoundManager::getListenerMaxDistance() const {
		return m_maxDistance;
	}

	void SoundManager::update() {
		if (m_state != SM_STATE_PLAY) {
			return;
		}
		AudioSpaceCoordinate listenerPos = getListenerPosition();
		double maxDistance = static_cast<double>(m_maxDistance);

		// first check emitters
		for (std::vector<SoundEmitter*>::iterator it = m_emitterVec.begin(); it != m_emitterVec.end(); ++it) {
			SoundEmitter* emitter = (*it);
			if (!emitter) {
				continue;
			}
			emitter->setCheckDifference();

			bool active = emitter->isActive();
			bool clip = emitter->getSoundClip();
			bool plays = !emitter->isFinished();
			// remove active without clip or stopped
			if (!clip || !plays) {
				if (active) {
					emitter->update();
					releaseSource(emitter);
				}
				continue;
			}

			bool inRange = true;
			if (emitter->isPosition()) {
				AudioSpaceCoordinate emitterPos = emitter->getPosition();
				double rx = listenerPos.x - emitterPos.x;
				double ry = listenerPos.y - emitterPos.y;
				double rz = listenerPos.z - emitterPos.z;
				inRange = maxDistance >= Mathd::Sqrt(rx*rx + ry*ry + rz*rz);
			}
			// remove active not in range
			if (!inRange) {
				if (active) {
					releaseSource(emitter);
				}
				continue;
			}
			if (!active && !m_freeSources.empty()) {
				setEmitterSource(emitter);
			}
		}
		// then update active
		for (std::map<SoundEmitter*, ALuint>::iterator it = m_activeEmitters.begin(); it != m_activeEmitters.end(); ++it) {
			it->first->update();
		}
	}

	SoundEmitter* SoundManager::getEmitter(uint32_t emitterId) const {
		return m_emitterVec.at(emitterId);
	}

	SoundEmitter* SoundManager::createEmitter() {
		SoundEmitter* ptr = NULL;
		for (uint32_t i = 0; i < m_emitterVec.size(); i++) {
			if (m_emitterVec.at(i) == NULL) {
				ptr = new SoundEmitter(this, i);
				m_emitterVec.at(i) = ptr;
				break;
			}
		}
		if (!ptr) {
			ptr = new SoundEmitter(this, m_emitterVec.size());
			m_emitterVec.push_back(ptr);
		}
		return ptr;
	}

	SoundEmitter* SoundManager::createEmitter(const std::string& name) {
		SoundEmitter* emitter = createEmitter();
		emitter->setSoundClip(SoundClipManager::instance()->get(name));
		return emitter;
	}

	void SoundManager::releaseEmitter(uint32_t emitterId) {
		SoundEmitter** ptr = &m_emitterVec.at(emitterId);
		if ((*ptr)->isActive()) {
			releaseSource(*ptr);
		}
		delete *ptr;
		*ptr = NULL;
	}

	void SoundManager::deleteEmitter(SoundEmitter* emitter) {
		releaseEmitter(emitter->getId());
	}

	void SoundManager::setEmitterSource(SoundEmitter* emitter) {
		std::pair<std::map<SoundEmitter*, ALuint>::iterator, bool> ret;
		ret = m_activeEmitters.insert(std::pair<SoundEmitter*, ALuint>(emitter, m_freeSources.front()));
		if (ret.second == false) {
			FL_WARN(_log, LMsg() << "SoundEmitter already have an source handler");
		}
		emitter->setSource(m_freeSources.front());
		m_freeSources.pop();
	}

	void SoundManager::releaseSource(SoundEmitter* emitter) {
		if (emitter->isActive()) {
			std::map<SoundEmitter*, ALuint>::iterator it = m_activeEmitters.find(emitter);
			if (it != m_activeEmitters.end()) {
				m_freeSources.push(it->second);
				m_activeEmitters.erase(it);
				emitter->setSource(0);
			} else {
				FL_WARN(_log, LMsg() << "SoundEmitter can not release source handler");
			}
		}
	}

	SoundEffect* SoundManager::createSoundEffect(SoundEffectType type) {
		return m_effectManager->createSoundEffect(type);
	}

	SoundEffect* SoundManager::createSoundEffectPreset(SoundEffectPreset type) {
		return m_effectManager->createSoundEffectPreset(type);
	}

	void SoundManager::deleteSoundEffect(SoundEffect* effect) {
		m_effectManager->deleteSoundEffect(effect);
	}

	void SoundManager::enableSoundEffect(SoundEffect* effect) {
		m_effectManager->enableSoundEffect(effect);
	}

	void SoundManager::disableSoundEffect(SoundEffect* effect) {
		m_effectManager->disableSoundEffect(effect);
	}

	void SoundManager::addEmitterToSoundEffect(SoundEffect* effect, SoundEmitter* emitter) {
		m_effectManager->addEmitterToSoundEffect(effect, emitter);
	}

	void SoundManager::removeEmitterFromSoundEffect(SoundEffect* effect, SoundEmitter* emitter) {
		m_effectManager->removeEmitterFromSoundEffect(effect, emitter);
	}

	void SoundManager::addSoundFilterToSoundEffect(SoundEffect* effect, SoundFilter* filter) {
		m_effectManager->addSoundFilterToSoundEffect(effect, filter);
	}

	void SoundManager::removeSoundFilterFromSoundEffect(SoundEffect* effect, SoundFilter* filter) {
		m_effectManager->removeSoundFilterFromSoundEffect(effect, filter);
	}

	void SoundManager::activateEffect(SoundEffect* effect, SoundEmitter* emitter) {
		m_effectManager->activateEffect(effect, emitter);
	}

	void SoundManager::deactivateEffect(SoundEffect* effect, SoundEmitter* emitter) {
		m_effectManager->deactivateEffect(effect, emitter);
	}

	SoundFilter* SoundManager::createSoundFilter(SoundFilterType type) {
		return m_effectManager->createSoundFilter(type);
	}

	void SoundManager::deleteSoundFilter(SoundFilter* filter) {
		m_effectManager->deleteSoundFilter(filter);
	}

	void SoundManager::enableDirectSoundFilter(SoundFilter* filter) {
		m_effectManager->enableDirectSoundFilter(filter);
	}

	void SoundManager::disableDirectSoundFilter(SoundFilter* filter) {
		m_effectManager->disableDirectSoundFilter(filter);
	}

	void SoundManager::addEmitterToDirectSoundFilter(SoundFilter* filter, SoundEmitter* emitter) {
		m_effectManager->addEmitterToDirectSoundFilter(filter, emitter);
	}

	void SoundManager::removeEmitterFromDirectSoundFilter(SoundFilter* filter, SoundEmitter* emitter) {
		m_effectManager->removeEmitterFromDirectSoundFilter(filter, emitter);
	}

	void SoundManager::activateFilter(SoundFilter* filter, SoundEmitter* emitter) {
		m_effectManager->activateFilter(filter, emitter);
	}

	void SoundManager::deactivateFilter(SoundFilter* filter, SoundEmitter* emitter) {
		m_effectManager->deactivateFilter(filter, emitter);
	}

	void SoundManager::addToGroup(SoundEmitter* emitter) {
		if (emitter->getGroup() != "") {
			m_groups[emitter->getGroup()].push_back(emitter);
		}
	}

	void SoundManager::removeFromGroup(SoundEmitter* emitter) {
		std::string group = emitter->getGroup();
		if (group == "") {
			return;
		}
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "SoundEmitter can not removed from unknown group");
			return;
		}
		bool found = false;
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		std::vector<SoundEmitter*>::iterator emitterEnd = groupIt->second.end();
		while (emitterIt != emitterEnd) {
			if ((*emitterIt) == emitter) {
				groupIt->second.erase(emitterIt++);
				found = true;
			} else {
				++emitterIt;
			}
		}
		if (!found) {
			FL_WARN(_log, LMsg() << "SoundEmitter could not be found in the given group.");
			return;
		}
	}

	void SoundManager::removeGroup(const std::string& group) {
		if (group == "") {
			return;
		}
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "SoundEmitter can not remove unknown group");
			return;
		}
		std::vector<SoundEmitter*> emitters = groupIt->second;
		for (std::vector<SoundEmitter*>::iterator it = emitters.begin(); it != emitters.end(); ++it) {
			(*it)->setGroup("");
		}
		m_groups.erase(group);
	}

	void SoundManager::removeAllGroups() {
		std::vector<std::string> groups;
		for (EmitterGroupsIterator it = m_groups.begin(); it != m_groups.end(); ++it) {
			groups.push_back(it->first);
		}
		for (std::vector<std::string>::iterator it = groups.begin(); it != groups.end(); ++it) {
			removeGroup(*it);
		}
		m_groups.clear();
	}

	void SoundManager::play(const std::string& group) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not played");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->play();
		}
	}

	void SoundManager::pause(const std::string& group) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not paused");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->pause();
		}
	}

	void SoundManager::stop(const std::string& group) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not stopped");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->stop();
		}
	}

	void SoundManager::rewind(const std::string& group) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not rewinded");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->rewind();
		}
	}

	void SoundManager::setGain(const std::string& group, float gain) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not set gain");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->setGain(gain);
		}
	}

	void SoundManager::setMaxGain(const std::string& group, float gain) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not set max gain");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->setMaxGain(gain);
		}
	}

	void SoundManager::setMinGain(const std::string& group, float gain) {
		EmitterGroupsIterator groupIt = m_groups.find(group);
		if (groupIt == m_groups.end()) {
			FL_WARN(_log, LMsg() << "Unknown group can not set min gain");
			return;
		}
		std::vector<SoundEmitter*>::iterator emitterIt = groupIt->second.begin();
		for (; emitterIt != groupIt->second.end(); ++emitterIt) {
			(*emitterIt)->setMinGain(gain);
		}
	}

} //FIFE