FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
soundeffectmanager.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 
24 // Platform specific includes
25 
26 // 3rd party library includes
27 
28 // FIFE includes
29 // These includes are split up in two parts, separated by one empty line
30 // First block: files included from the FIFE root src directory
31 // Second block: files included from the same folder
32 #include "audio/soundemitter.h"
33 #include "util/log/logger.h"
34 #include "util/base/exception.h"
35 
36 #include "soundeffect.h"
37 #include "soundfilter.h"
38 #include "soundeffectmanager.h"
39 
40 namespace FIFE {
44  static Logger _log(LM_AUDIO);
45 
46 
47  // Effect Slots
48  LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots = NULL;
49  LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots = NULL;
50  LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot = NULL;
51  LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti = NULL;
52  LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv = NULL;
53  LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf = NULL;
54  LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv = NULL;
55  LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti = NULL;
56  LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv = NULL;
57  LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf = NULL;
58  LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv = NULL;
59 
60  // Effects
61  LPALGENEFFECTS alGenEffects = NULL;
62  LPALDELETEEFFECTS alDeleteEffects = NULL;
63  LPALISEFFECT alIsEffect = NULL;
64  LPALEFFECTI alEffecti = NULL;
65  LPALEFFECTIV alEffectiv = NULL;
66  LPALEFFECTF alEffectf = NULL;
67  LPALEFFECTFV alEffectfv = NULL;
68  LPALGETEFFECTI alGetEffecti = NULL;
69  LPALGETEFFECTIV alGetEffectiv = NULL;
70  LPALGETEFFECTF alGetEffectf = NULL;
71  LPALGETEFFECTFV alGetEffectfv = NULL;
72 
73  // Filters
74  LPALGENFILTERS alGenFilters = NULL;
75  LPALDELETEFILTERS alDeleteFilters = NULL;
76  LPALISFILTER alIsFilter = NULL;
77  LPALFILTERI alFilteri = NULL;
78  LPALFILTERIV alFilteriv = NULL;
79  LPALFILTERF alFilterf = NULL;
80  LPALFILTERFV alFilterfv = NULL;
81  LPALGETFILTERI alGetFilteri = NULL;
82  LPALGETFILTERIV alGetFilteriv = NULL;
83  LPALGETFILTERF alGetFilterf = NULL;
84  LPALGETFILTERFV alGetFilterfv = NULL;
85 
86 
88  m_device(NULL),
89  m_active(false),
90  m_createdSlots(0),
91  m_maxSlots(0) {
92 
93  }
94 
96  // SoundEmitters are destroyed beforehand
97  for (std::vector<SoundFilter*>::iterator it = m_filters.begin(); it != m_filters.end(); ++it) {
98  delete *it;
99  }
100  for (std::vector<SoundEffect*>::iterator it = m_effects.begin(); it != m_effects.end(); ++it) {
101  delete *it;
102  }
103  }
104 
105  void SoundEffectManager::init(ALCdevice* device) {
106  m_device = device;
107 
108  if (alcIsExtensionPresent(m_device, "ALC_EXT_EFX") == AL_FALSE) {
109  FL_WARN(_log, LMsg() << "ALC_EXT_EFX not supported!\n");
110  return;
111  }
112 
113  // Slot functions
114  alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots");
115  alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots");
116  alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot");
117  alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti");
118  alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)alGetProcAddress("alAuxiliaryEffectSlotiv");
119  alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf");
120  alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)alGetProcAddress("alAuxiliaryEffectSlotfv");
121  alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)alGetProcAddress("alGetAuxiliaryEffectSloti");
122  alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)alGetProcAddress("alGetAuxiliaryEffectSlotiv");
123  alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)alGetProcAddress("alGetAuxiliaryEffectSlotf");
124  alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)alGetProcAddress("alGetAuxiliaryEffectSlotfv");
125  if (!(alGenAuxiliaryEffectSlots && alDeleteAuxiliaryEffectSlots && alIsAuxiliaryEffectSlot &&
126  alAuxiliaryEffectSloti && alAuxiliaryEffectSlotiv && alAuxiliaryEffectSlotf &&
127  alAuxiliaryEffectSlotfv && alGetAuxiliaryEffectSloti && alGetAuxiliaryEffectSlotiv &&
128  alGetAuxiliaryEffectSlotf && alGetAuxiliaryEffectSlotfv)) {
129  FL_WARN(_log, LMsg() << "Failed initializing slot function pointers\n");
130  return;
131  }
132 
133  // Effect functions
134  alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects");
135  alDeleteEffects = (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects");
136  alIsEffect = (LPALISEFFECT)alGetProcAddress("alIsEffect");
137  alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti");
138  alEffectiv = (LPALEFFECTIV)alGetProcAddress("alEffectiv");
139  alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf");
140  alEffectfv = (LPALEFFECTFV)alGetProcAddress("alEffectfv");
141  alGetEffecti = (LPALGETEFFECTI)alGetProcAddress("alGetEffecti");
142  alGetEffectiv = (LPALGETEFFECTIV)alGetProcAddress("alGetEffectiv");
143  alGetEffectf = (LPALGETEFFECTF)alGetProcAddress("alGetEffectf");
144  alGetEffectfv = (LPALGETEFFECTFV)alGetProcAddress("alGetEffectfv");
145  if (!(alGenEffects && alDeleteEffects && alIsEffect && alEffecti && alEffectiv && alEffectf &&
146  alEffectfv && alGetEffecti && alGetEffectiv && alGetEffectf && alGetEffectfv)) {
147  FL_WARN(_log, LMsg() << "Failed initializing effect function pointers\n");
148  return;
149  }
150 
151  // Filter functions
152  alGenFilters = (LPALGENFILTERS)alGetProcAddress("alGenFilters");
153  alDeleteFilters = (LPALDELETEFILTERS)alGetProcAddress("alDeleteFilters");
154  alIsFilter = (LPALISFILTER)alGetProcAddress("alIsFilter");
155  alFilteri = (LPALFILTERI)alGetProcAddress("alFilteri");
156  alFilteriv = (LPALFILTERIV)alGetProcAddress("alFilteriv");
157  alFilterf = (LPALFILTERF)alGetProcAddress("alFilterf");
158  alFilterfv = (LPALFILTERFV)alGetProcAddress("alFilterfv");
159  alGetFilteri = (LPALGETFILTERI)alGetProcAddress("alGetFilteri");
160  alGetFilteriv = (LPALGETFILTERIV)alGetProcAddress("alGetFilteriv");
161  alGetFilterf = (LPALGETFILTERF)alGetProcAddress("alGetFilterf");
162  alGetFilterfv = (LPALGETFILTERFV)alGetProcAddress("alGetFilterfv");
163  if (!(alGenFilters && alDeleteFilters && alIsFilter && alFilteri && alFilteriv && alFilterf &&
164  alFilterfv && alGetFilteri && alGetFilteriv && alGetFilterf && alGetFilterfv)) {
165  FL_WARN(_log, LMsg() << "Failed initializing filter function pointers\n");
166  return;
167  }
168 
169  m_active = true;
170 
171  // create max effect slots
172  for (uint16_t i = 0; i < MAX_EFFECT_SLOTS; i++) {
174  if (alGetError() != AL_NO_ERROR) {
175  break;
176  }
177 
178  m_freeSlots.push(m_effectSlots[i]);
179  m_createdSlots++;
180  }
181  // fetch maximal slots per source
182  alcGetIntegerv(m_device, ALC_MAX_AUXILIARY_SENDS, 1, &m_maxSlots);
183  // prepares the presets
184  createPresets();
185  }
186 
188  return m_active;
189  }
190 
192  SoundEffect* effect = NULL;
193  if (type == SE_EFFECT_REVERB) {
194  effect = new Reverb();
195  } else if (type == SE_EFFECT_CHORUS) {
196  effect = new Chorus();
197  } else if (type == SE_EFFECT_DISTORTION) {
198  effect = new Distortion();
199  } else if (type == SE_EFFECT_ECHO) {
200  effect = new Echo();
201  } else if (type == SE_EFFECT_FLANGER) {
202  effect = new Flanger();
203  } else if (type == SE_EFFECT_FREQUENCY_SHIFTER) {
204  effect = new FrequencyShifter();
205  } else if (type == SE_EFFECT_VOCAL_MORPHER) {
206  effect = new VocalMorpher();
207  } else if (type == SE_EFFECT_PITCH_SHIFTER) {
208  effect = new PitchShifter();
209  } else if (type == SE_EFFECT_RING_MODULATOR) {
210  effect = new RingModulator();
211  } else if (type == SE_EFFECT_AUTOWAH) {
212  effect = new Autowah();
213  } else if (type == SE_EFFECT_COMPRESSOR) {
214  effect = new Compressor();
215  } else if (type == SE_EFFECT_EQUALIZER) {
216  effect = new Equalizer();
217  } else if (type == SE_EFFECT_EAXREVERB) {
218  effect = new EaxReverb();
219  }
220  if (effect) {
221  m_effects.push_back(effect);
222  }
223  return effect;
224  }
225 
227  std::map<SoundEffectPreset, EFXEAXREVERBPROPERTIES>::iterator it = m_presets.find(type);
228  if (it == m_presets.end()) {
229  return NULL;
230  }
231  SoundEffect* effect = new EaxReverb();
232  m_effects.push_back(effect);
233 
234  EaxReverb* reverb = static_cast<EaxReverb*>(effect);
235  reverb->loadPreset(it->second);
236  return effect;
237  }
238 
240  disableSoundEffect(effect);
241  if (effect->getFilter()) {
242  removeSoundFilterFromSoundEffect(effect, effect->getFilter());
243  }
244  for (std::vector<SoundEffect*>::iterator it = m_effects.begin(); it != m_effects.end(); ++it) {
245  if (effect == *it) {
246  SoundEffectEmitterMap::iterator effectIt = m_effectEmitters.find(effect);
247  if (effectIt != m_effectEmitters.end()) {
248  std::vector<SoundEmitter*>::iterator emitterIt = effectIt->second.begin();
249  for (; emitterIt != effectIt->second.end(); ++emitterIt) {
250  (*emitterIt)->removeEffect(effect);
251  }
252  }
253  m_effectEmitters.erase(effectIt);
254  delete *it;
255  m_effects.erase(it);
256  break;
257  }
258  }
259  }
260 
262  if (m_freeSlots.empty() || effect->isEnabled()) {
263  if (m_freeSlots.empty()) {
264  FL_WARN(_log, LMsg() << "No free auxiliary slot available");
265  }
266  return;
267  }
268 
269  ALuint slot = m_freeSlots.front();
270  ALuint filter = effect->getFilter() ? effect->getFilter()->getFilterId() : AL_FILTER_NULL;
271  m_freeSlots.pop();
272  alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, effect->getEffectId());
273  effect->setSlotId(slot);
274  effect->setEnabled(true);
275  SoundEffectEmitterMap::iterator effectIt = m_effectEmitters.find(effect);
276  if (effectIt != m_effectEmitters.end()) {
277  std::vector<SoundEmitter*>::iterator emitterIt = effectIt->second.begin();
278  for (; emitterIt != effectIt->second.end(); ++emitterIt) {
279  if (!(*emitterIt)->isActive()) {
280  continue;
281  }
282  activateEffect(effect, *emitterIt);
283  }
284  }
285  }
286 
288  if (!effect->isEnabled()) {
289  return;
290  }
291  alAuxiliaryEffectSloti(effect->getSlotId(), AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL);
292  m_freeSlots.push(effect->getSlotId());
293  effect->setSlotId(0);
294 
295  SoundEffectEmitterMap::iterator effectIt = m_effectEmitters.find(effect);
296  if (effectIt != m_effectEmitters.end()) {
297  std::vector<SoundEmitter*>::iterator emitterIt = effectIt->second.begin();
298  for (; emitterIt != effectIt->second.end(); ++emitterIt) {
299  deactivateEffect(effect, *emitterIt);
300  }
301  }
302  effect->setEnabled(false);
303  }
304 
306  if (emitter->getEffectCount() == m_maxSlots) {
307  FL_WARN(_log, LMsg() << "Maximal effect number for SoundEmitter reached");
308  return;
309  }
310  m_effectEmitters[effect].push_back(emitter);
311  emitter->addEffect(effect);
312  if (emitter-isActive()) {
313  activateEffect(effect, emitter);
314  }
315  }
316 
318  SoundEffectEmitterMap::iterator effectIt = m_effectEmitters.find(effect);
319  if (effectIt == m_effectEmitters.end()) {
320  FL_WARN(_log, LMsg() << "SoundEmitter can not removed from unknown effect");
321  return;
322  }
323  bool found = false;
324  std::vector<SoundEmitter*>::iterator emitterIt = effectIt->second.begin();
325  std::vector<SoundEmitter*>::iterator emitterEnd = effectIt->second.end();
326  while (emitterIt != emitterEnd) {
327  if ((*emitterIt) == emitter) {
328  if (emitter->isActive()) {
329  deactivateEffect(effect, emitter);
330  }
331  emitter->removeEffect(effect);
332  effectIt->second.erase(emitterIt++);
333  found = true;
334  } else {
335  ++emitterIt;
336  }
337  }
338  if (!found) {
339  FL_WARN(_log, LMsg() << "SoundEmitter could not be found for the given effect.");
340  return;
341  }
342  }
343 
345  if (effect->getFilter()) {
346  FL_WARN(_log, LMsg() << "SoundEffect already has a filter");
347  return;
348  }
349  effect->setFilter(filter);
350  m_filterdEffects[filter].push_back(effect);
351  if (effect->isEnabled()) {
352  disableSoundEffect(effect);
353  enableSoundEffect(effect);
354  }
355  }
356 
358  SoundFilterEffectMap::iterator filterIt = m_filterdEffects.find(filter);
359  if (filterIt == m_filterdEffects.end()) {
360  FL_WARN(_log, LMsg() << "SoundEffect can not removed from unknown filter");
361  return;
362  }
363  bool found = false;
364  std::vector<SoundEffect*>::iterator effectIt = filterIt->second.begin();
365  std::vector<SoundEffect*>::iterator effectEnd = filterIt->second.end();
366  while (effectIt != effectEnd) {
367  if ((*effectIt) == effect) {
368  effect->setFilter(NULL);
369  if (effect->isEnabled()) {
370  disableSoundEffect(effect);
371  enableSoundEffect(effect);
372  }
373  filterIt->second.erase(effectIt++);
374  found = true;
375  }
376  else {
377  ++effectIt;
378  }
379  }
380  if (!found) {
381  FL_WARN(_log, LMsg() << "SoundEffect could not be found for the given filter.");
382  return;
383  }
384  }
385 
387  if (!effect->isEnabled()) {
388  return;
389  }
390  ALuint number = static_cast<ALuint>(emitter->getEffectNumber(effect));
391  ALuint filter = effect->getFilter() ? effect->getFilter()->getFilterId() : AL_FILTER_NULL;
392  alSource3i(emitter->getSource(), AL_AUXILIARY_SEND_FILTER, effect->getSlotId(), number, filter);
393  }
394 
396  if (!effect->isEnabled()) {
397  return;
398  }
399  ALuint number = static_cast<ALuint>(emitter->getEffectNumber(effect));
400  alSource3i(emitter->getSource(), AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, number, AL_FILTER_NULL);
401  }
402 
404  SoundFilter* filter = new SoundFilter(type);
405  m_filters.push_back(filter);
406  return filter;
407  }
408 
410  disableDirectSoundFilter(filter);
411  for (std::vector<SoundFilter*>::iterator it = m_filters.begin(); it != m_filters.end(); ++it) {
412  if (filter == *it) {
413  SoundFilterEmitterMap::iterator filterIt = m_filterdEmitters.find(filter);
414  if (filterIt != m_filterdEmitters.end()) {
415  std::vector<SoundEmitter*>::iterator emitterIt = filterIt->second.begin();
416  for (; emitterIt != filterIt->second.end(); ++emitterIt) {
417  (*emitterIt)->setDirectFilter(NULL);
418  }
419  }
420  m_filterdEmitters.erase(filterIt);
421  SoundFilterEffectMap::iterator filterItt = m_filterdEffects.find(filter);
422  if (filterItt != m_filterdEffects.end()) {
423  std::vector<SoundEffect*>::iterator effectIt = filterItt->second.begin();
424  for (; effectIt != filterItt->second.end(); ++effectIt) {
425  (*effectIt)->setFilter(NULL);
426  if ((*effectIt)->isEnabled()) {
427  disableSoundEffect(*effectIt);
428  enableSoundEffect(*effectIt);
429  }
430  }
431  }
432  m_filterdEffects.erase(filterItt);
433  delete *it;
434  m_filters.erase(it);
435  break;
436  }
437  }
438  }
439 
441  if (filter->isEnabled()) {
442  return;
443  }
444  filter->setEnabled(true);
445  SoundFilterEmitterMap::iterator filterIt = m_filterdEmitters.find(filter);
446  if (filterIt != m_filterdEmitters.end()) {
447  std::vector<SoundEmitter*>::iterator emitterIt = filterIt->second.begin();
448  for (; emitterIt != filterIt->second.end(); ++emitterIt) {
449  if ((*emitterIt)->isActive()) {
450  activateFilter(filter, *emitterIt);
451  }
452  }
453  }
454  }
455 
457  if (!filter->isEnabled()) {
458  return;
459  }
460  SoundFilterEmitterMap::iterator filterIt = m_filterdEmitters.find(filter);
461  if (filterIt != m_filterdEmitters.end()) {
462  std::vector<SoundEmitter*>::iterator emitterIt = filterIt->second.begin();
463  for (; emitterIt != filterIt->second.end(); ++emitterIt) {
464  if ((*emitterIt)->isActive()) {
465  deactivateFilter(filter, *emitterIt);
466  }
467  }
468  }
469  filter->setEnabled(false);
470  }
471 
473  if (emitter->getDirectFilter()) {
474  FL_WARN(_log, LMsg() << "SoundEmitter already has a direct filter");
475  return;
476  }
477  emitter->setDirectFilter(filter);
478  m_filterdEmitters[filter].push_back(emitter);
479  if (emitter->isActive()) {
480  activateFilter(filter, emitter);
481  }
482  }
483 
485  SoundFilterEmitterMap::iterator filterIt = m_filterdEmitters.find(filter);
486  if (filterIt == m_filterdEmitters.end()) {
487  FL_WARN(_log, LMsg() << "SoundEmitter can not removed from unknown filter");
488  return;
489  }
490  bool found = false;
491  std::vector<SoundEmitter*>::iterator emitterIt = filterIt->second.begin();
492  std::vector<SoundEmitter*>::iterator emitterEnd = filterIt->second.end();
493  while (emitterIt != emitterEnd) {
494  if ((*emitterIt) == emitter) {
495  if (emitter->isActive()) {
496  deactivateFilter(filter, emitter);
497  }
498  emitter->setDirectFilter(NULL);
499  filterIt->second.erase(emitterIt++);
500  found = true;
501  }
502  else {
503  ++emitterIt;
504  }
505  }
506  if (!found) {
507  FL_WARN(_log, LMsg() << "SoundEmitter could not be found for the given filter.");
508  return;
509  }
510  }
511 
513  if (filter->isEnabled()) {
514  alSourcei(emitter->getSource(), AL_DIRECT_FILTER, filter->getFilterId());
515  }
516  }
517 
519  if (filter->isEnabled()) {
520  alSourcei(emitter->getSource(), AL_DIRECT_FILTER, AL_FILTER_NULL);
521  }
522  }
523 
525  EFXEAXREVERBPROPERTIES prop1 = EFX_REVERB_PRESET_GENERIC;
526  EFXEAXREVERBPROPERTIES prop2 = EFX_REVERB_PRESET_PADDEDCELL;
527  EFXEAXREVERBPROPERTIES prop3 = EFX_REVERB_PRESET_ROOM;
528  EFXEAXREVERBPROPERTIES prop4 = EFX_REVERB_PRESET_BATHROOM;
529  EFXEAXREVERBPROPERTIES prop5 = EFX_REVERB_PRESET_LIVINGROOM;
530  EFXEAXREVERBPROPERTIES prop6 = EFX_REVERB_PRESET_STONEROOM;
531  EFXEAXREVERBPROPERTIES prop7 = EFX_REVERB_PRESET_AUDITORIUM;
532  EFXEAXREVERBPROPERTIES prop8 = EFX_REVERB_PRESET_CONCERTHALL;
533  EFXEAXREVERBPROPERTIES prop9 = EFX_REVERB_PRESET_CAVE;
534  EFXEAXREVERBPROPERTIES prop10 = EFX_REVERB_PRESET_ARENA;
535  EFXEAXREVERBPROPERTIES prop11 = EFX_REVERB_PRESET_HANGAR;
536  EFXEAXREVERBPROPERTIES prop12 = EFX_REVERB_PRESET_CARPETEDHALLWAY;
537  EFXEAXREVERBPROPERTIES prop13 = EFX_REVERB_PRESET_HALLWAY;
538  EFXEAXREVERBPROPERTIES prop14 = EFX_REVERB_PRESET_STONECORRIDOR;
539  EFXEAXREVERBPROPERTIES prop15 = EFX_REVERB_PRESET_ALLEY;
540  EFXEAXREVERBPROPERTIES prop16 = EFX_REVERB_PRESET_FOREST;
541  EFXEAXREVERBPROPERTIES prop17 = EFX_REVERB_PRESET_CITY;
542  EFXEAXREVERBPROPERTIES prop18 = EFX_REVERB_PRESET_MOUNTAINS;
543  EFXEAXREVERBPROPERTIES prop19 = EFX_REVERB_PRESET_QUARRY;
544  EFXEAXREVERBPROPERTIES prop20 = EFX_REVERB_PRESET_PLAIN;
545  EFXEAXREVERBPROPERTIES prop21 = EFX_REVERB_PRESET_PARKINGLOT;
546  EFXEAXREVERBPROPERTIES prop22 = EFX_REVERB_PRESET_SEWERPIPE;
547  EFXEAXREVERBPROPERTIES prop23 = EFX_REVERB_PRESET_UNDERWATER;
548  EFXEAXREVERBPROPERTIES prop24 = EFX_REVERB_PRESET_DRUGGED;
549  EFXEAXREVERBPROPERTIES prop25 = EFX_REVERB_PRESET_DIZZY;
550  EFXEAXREVERBPROPERTIES prop26 = EFX_REVERB_PRESET_PSYCHOTIC;
551  EFXEAXREVERBPROPERTIES prop27 = EFX_REVERB_PRESET_CASTLE_SMALLROOM;
552  EFXEAXREVERBPROPERTIES prop28 = EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE;
553  EFXEAXREVERBPROPERTIES prop29 = EFX_REVERB_PRESET_CASTLE_MEDIUMROOM;
554  EFXEAXREVERBPROPERTIES prop30 = EFX_REVERB_PRESET_CASTLE_LARGEROOM;
555  EFXEAXREVERBPROPERTIES prop31 = EFX_REVERB_PRESET_CASTLE_LONGPASSAGE;
556  EFXEAXREVERBPROPERTIES prop32 = EFX_REVERB_PRESET_CASTLE_HALL;
557  EFXEAXREVERBPROPERTIES prop33 = EFX_REVERB_PRESET_CASTLE_CUPBOARD;
558  EFXEAXREVERBPROPERTIES prop34 = EFX_REVERB_PRESET_CASTLE_COURTYARD;
559  EFXEAXREVERBPROPERTIES prop35 = EFX_REVERB_PRESET_CASTLE_ALCOVE;
560  EFXEAXREVERBPROPERTIES prop36 = EFX_REVERB_PRESET_FACTORY_SMALLROOM;
561  EFXEAXREVERBPROPERTIES prop37 = EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE;
562  EFXEAXREVERBPROPERTIES prop38 = EFX_REVERB_PRESET_FACTORY_MEDIUMROOM;
563  EFXEAXREVERBPROPERTIES prop39 = EFX_REVERB_PRESET_FACTORY_LARGEROOM;
564  EFXEAXREVERBPROPERTIES prop40 = EFX_REVERB_PRESET_FACTORY_LONGPASSAGE;
565  EFXEAXREVERBPROPERTIES prop41 = EFX_REVERB_PRESET_FACTORY_HALL;
566  EFXEAXREVERBPROPERTIES prop42 = EFX_REVERB_PRESET_FACTORY_CUPBOARD;
567  EFXEAXREVERBPROPERTIES prop43 = EFX_REVERB_PRESET_FACTORY_COURTYARD;
568  EFXEAXREVERBPROPERTIES prop44 = EFX_REVERB_PRESET_FACTORY_ALCOVE;
569  EFXEAXREVERBPROPERTIES prop45 = EFX_REVERB_PRESET_ICEPALACE_SMALLROOM;
570  EFXEAXREVERBPROPERTIES prop46 = EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE;
571  EFXEAXREVERBPROPERTIES prop47 = EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM;
572  EFXEAXREVERBPROPERTIES prop48 = EFX_REVERB_PRESET_ICEPALACE_LARGEROOM;
573  EFXEAXREVERBPROPERTIES prop49 = EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE;
574  EFXEAXREVERBPROPERTIES prop50 = EFX_REVERB_PRESET_ICEPALACE_HALL;
575  EFXEAXREVERBPROPERTIES prop51 = EFX_REVERB_PRESET_ICEPALACE_CUPBOARD;
576  EFXEAXREVERBPROPERTIES prop52 = EFX_REVERB_PRESET_ICEPALACE_COURTYARD;
577  EFXEAXREVERBPROPERTIES prop53 = EFX_REVERB_PRESET_ICEPALACE_ALCOVE;
578  EFXEAXREVERBPROPERTIES prop54 = EFX_REVERB_PRESET_SPACESTATION_SMALLROOM;
579  EFXEAXREVERBPROPERTIES prop55 = EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE;
580  EFXEAXREVERBPROPERTIES prop56 = EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM;
581  EFXEAXREVERBPROPERTIES prop57 = EFX_REVERB_PRESET_SPACESTATION_LARGEROOM;
582  EFXEAXREVERBPROPERTIES prop58 = EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE;
583  EFXEAXREVERBPROPERTIES prop59 = EFX_REVERB_PRESET_SPACESTATION_HALL;
584  EFXEAXREVERBPROPERTIES prop60 = EFX_REVERB_PRESET_SPACESTATION_CUPBOARD;
585  EFXEAXREVERBPROPERTIES prop61 = EFX_REVERB_PRESET_SPACESTATION_ALCOVE;
586  EFXEAXREVERBPROPERTIES prop62 = EFX_REVERB_PRESET_WOODEN_SMALLROOM;
587  EFXEAXREVERBPROPERTIES prop63 = EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE;
588  EFXEAXREVERBPROPERTIES prop64 = EFX_REVERB_PRESET_WOODEN_MEDIUMROOM;
589  EFXEAXREVERBPROPERTIES prop65 = EFX_REVERB_PRESET_WOODEN_LARGEROOM;
590  EFXEAXREVERBPROPERTIES prop66 = EFX_REVERB_PRESET_WOODEN_LONGPASSAGE;
591  EFXEAXREVERBPROPERTIES prop67 = EFX_REVERB_PRESET_WOODEN_HALL;
592  EFXEAXREVERBPROPERTIES prop68 = EFX_REVERB_PRESET_WOODEN_CUPBOARD;
593  EFXEAXREVERBPROPERTIES prop69 = EFX_REVERB_PRESET_WOODEN_COURTYARD;
594  EFXEAXREVERBPROPERTIES prop70 = EFX_REVERB_PRESET_WOODEN_ALCOVE;
595  EFXEAXREVERBPROPERTIES prop71 = EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM;
596  EFXEAXREVERBPROPERTIES prop72 = EFX_REVERB_PRESET_SPORT_SQUASHCOURT;
597  EFXEAXREVERBPROPERTIES prop73 = EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL;
598  EFXEAXREVERBPROPERTIES prop74 = EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL;
599  EFXEAXREVERBPROPERTIES prop75 = EFX_REVERB_PRESET_SPORT_GYMNASIUM;
600  EFXEAXREVERBPROPERTIES prop76 = EFX_REVERB_PRESET_SPORT_FULLSTADIUM;
601  EFXEAXREVERBPROPERTIES prop77 = EFX_REVERB_PRESET_SPORT_STADIUMTANNOY;
602  EFXEAXREVERBPROPERTIES prop78 = EFX_REVERB_PRESET_PREFAB_WORKSHOP;
603  EFXEAXREVERBPROPERTIES prop79 = EFX_REVERB_PRESET_PREFAB_SCHOOLROOM;
604  EFXEAXREVERBPROPERTIES prop80 = EFX_REVERB_PRESET_PREFAB_PRACTISEROOM;
605  EFXEAXREVERBPROPERTIES prop81 = EFX_REVERB_PRESET_PREFAB_OUTHOUSE;
606  EFXEAXREVERBPROPERTIES prop82 = EFX_REVERB_PRESET_PREFAB_CARAVAN;
607  EFXEAXREVERBPROPERTIES prop83 = EFX_REVERB_PRESET_DOME_TOMB;
608  EFXEAXREVERBPROPERTIES prop84 = EFX_REVERB_PRESET_PIPE_SMALL;
609  EFXEAXREVERBPROPERTIES prop85 = EFX_REVERB_PRESET_DOME_SAINTPAULS;
610  EFXEAXREVERBPROPERTIES prop86 = EFX_REVERB_PRESET_PIPE_LONGTHIN;
611  EFXEAXREVERBPROPERTIES prop87 = EFX_REVERB_PRESET_PIPE_LARGE;
612  EFXEAXREVERBPROPERTIES prop88 = EFX_REVERB_PRESET_PIPE_RESONANT;
613  EFXEAXREVERBPROPERTIES prop89 = EFX_REVERB_PRESET_OUTDOORS_BACKYARD;
614  EFXEAXREVERBPROPERTIES prop90 = EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS;
615  EFXEAXREVERBPROPERTIES prop91 = EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON;
616  EFXEAXREVERBPROPERTIES prop92 = EFX_REVERB_PRESET_OUTDOORS_CREEK;
617  EFXEAXREVERBPROPERTIES prop93 = EFX_REVERB_PRESET_OUTDOORS_VALLEY;
618  EFXEAXREVERBPROPERTIES prop94 = EFX_REVERB_PRESET_MOOD_HEAVEN;
619  EFXEAXREVERBPROPERTIES prop95 = EFX_REVERB_PRESET_MOOD_HELL;
620  EFXEAXREVERBPROPERTIES prop96 = EFX_REVERB_PRESET_MOOD_MEMORY;
621  EFXEAXREVERBPROPERTIES prop97 = EFX_REVERB_PRESET_DRIVING_COMMENTATOR;
622  EFXEAXREVERBPROPERTIES prop98 = EFX_REVERB_PRESET_DRIVING_PITGARAGE;
623  EFXEAXREVERBPROPERTIES prop99 = EFX_REVERB_PRESET_DRIVING_INCAR_RACER;
624  EFXEAXREVERBPROPERTIES prop100 = EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS;
625  EFXEAXREVERBPROPERTIES prop101 = EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY;
626  EFXEAXREVERBPROPERTIES prop102 = EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND;
627  EFXEAXREVERBPROPERTIES prop103 = EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND;
628  EFXEAXREVERBPROPERTIES prop104 = EFX_REVERB_PRESET_DRIVING_TUNNEL;
629  EFXEAXREVERBPROPERTIES prop105 = EFX_REVERB_PRESET_CITY_STREETS;
630  EFXEAXREVERBPROPERTIES prop106 = EFX_REVERB_PRESET_CITY_SUBWAY;
631  EFXEAXREVERBPROPERTIES prop107 = EFX_REVERB_PRESET_CITY_MUSEUM;
632  EFXEAXREVERBPROPERTIES prop108 = EFX_REVERB_PRESET_CITY_LIBRARY;
633  EFXEAXREVERBPROPERTIES prop109 = EFX_REVERB_PRESET_CITY_UNDERPASS;
634  EFXEAXREVERBPROPERTIES prop110 = EFX_REVERB_PRESET_CITY_ABANDONED;
635  EFXEAXREVERBPROPERTIES prop111 = EFX_REVERB_PRESET_DUSTYROOM;
636  EFXEAXREVERBPROPERTIES prop112 = EFX_REVERB_PRESET_CHAPEL;
637  EFXEAXREVERBPROPERTIES prop113 = EFX_REVERB_PRESET_SMALLWATERROOM;
638 
639  m_presets[SE_PRESET_GENERIC] = prop1;
641  m_presets[SE_PRESET_ROOM] = prop3;
642  m_presets[SE_PRESET_BATHROOM] = prop4;
647  m_presets[SE_PRESET_CAVE] = prop9;
648  m_presets[SE_PRESET_ARENA] = prop10;
649  m_presets[SE_PRESET_HANGAR] = prop11;
651  m_presets[SE_PRESET_HALLWAY] = prop13;
653  m_presets[SE_PRESET_ALLEY] = prop15;
654  m_presets[SE_PRESET_FOREST] = prop16;
655  m_presets[SE_PRESET_CITY] = prop17;
656  m_presets[SE_PRESET_MOUNTAINS] = prop18;
657  m_presets[SE_PRESET_QUARRY] = prop19;
658  m_presets[SE_PRESET_PLAIN] = prop20;
660  m_presets[SE_PRESET_SEWERPIPE] = prop22;
662  m_presets[SE_PRESET_DRUGGED] = prop24;
663  m_presets[SE_PRESET_DIZZY] = prop25;
664  m_presets[SE_PRESET_PSYCHOTIC] = prop26;
721  m_presets[SE_PRESET_DOME_TOMB] = prop83;
733  m_presets[SE_PRESET_MOOD_HELL] = prop95;
744  m_presets[SE_PRESET_CITY_SUBWAY] = prop106;
745  m_presets[SE_PRESET_CITY_MUSEUM] = prop107;
749  m_presets[SE_PRESET_DUSTYROOM] = prop111;
750  m_presets[SE_PRESET_CHAPEL] = prop112;
752  }
753 
754 } //FIFE
LPALFILTERFV alFilterfv
LPALFILTERI alFilteri
#define FL_WARN(logger, msg)
Definition: logger.h:72
The distortion effect simulates turning up (overdriving) the gain stage on a guitar amplifier or addi...
Definition: soundeffect.h:331
void setEnabled(bool enabled)
Enables or disables the effect.
Definition: soundeffect.cpp:75
void enableDirectSoundFilter(SoundFilter *filter)
Enables given direct SoundFilter.
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot
SoundFilterEmitterMap m_filterdEmitters
void removeEmitterFromSoundEffect(SoundEffect *effect, SoundEmitter *emitter)
Removes given SoundEmitter from the specific SoundEffect.
LPALEFFECTF alEffectf
LPALFILTERF alFilterf
The Automatic Gain Control effect performs the same task as a studio compressor – evening out the aud...
Definition: soundeffect.h:788
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv
void init(ALCdevice *device)
Initializes the effect system.
ALuint getSource() const
Return openAl-source.
void deactivateFilter(SoundFilter *filter, SoundEmitter *emitter)
Internal function to do the OpenAL calls to deactivate the SoundFilter for the SoundEmitter.
void removeEffect(SoundEffect *effect)
Removes effect.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
Definition: logger.h:82
LPALISEFFECT alIsEffect
SoundEffectPreset
Presets for EAX Reverb.
Definition: soundconfig.h:67
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv
void activateEffect(SoundEffect *effect, SoundEmitter *emitter)
Internal function to do the OpenAL calls to activate the SoundEffect for the SoundEmitter.
bool m_active
If sound effect module is active.
void deleteSoundFilter(SoundFilter *filter)
Deletes given SoundFilter.
ALCdevice * m_device
OpenAL device.
SoundFilter * getFilter()
Return sound filter or NULL.
Definition: soundeffect.cpp:87
The vocal morpher consists of a pair of 4-band formant filters, used to impose vocal tract effects up...
Definition: soundeffect.h:582
ALint m_maxSlots
Maximal effect slots per Source.
SoundEffect * createSoundEffect(SoundEffectType type)
Creates SoundEffect of the specific type.
Base class for Efx sound effects.
Definition: soundeffect.h:46
The class defines filters.
Definition: soundfilter.h:43
The chorus effect essentially replays the input audio accompanied by another slightly delayed version...
Definition: soundeffect.h:256
void addSoundFilterToSoundEffect(SoundEffect *effect, SoundFilter *filter)
Adds given SoundFilter to the SoundEffect.
static Logger _log(LM_AUDIO)
void disableSoundEffect(SoundEffect *effect)
Disables given SoundEffect.
void createPresets()
Inital the presets.
LPALGETFILTERFV alGetFilterfv
LPALGENFILTERS alGenFilters
SoundEffectEmitterMap m_effectEmitters
SoundFilterEffectMap m_filterdEffects
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv
void addEmitterToDirectSoundFilter(SoundFilter *filter, SoundEmitter *emitter)
Adds given SoundEmitter to the specific direct SoundFilter Note: A SoundEmitter can only have one dir...
void removeSoundFilterFromSoundEffect(SoundEffect *effect, SoundFilter *filter)
Removes given SoundFilter from the SoundEffect.
LPALGETFILTERIV alGetFilteriv
ALuint getSlotId()
Return the OpenAL auxiliary slot handle.
Definition: soundeffect.cpp:67
uint8_t getEffectCount()
Return the number of effects.
LPALGETFILTERF alGetFilterf
void disableDirectSoundFilter(SoundFilter *filter)
Disables given SoundFilter.
LPALDELETEFILTERS alDeleteFilters
LPALGENEFFECTS alGenEffects
LPALFILTERIV alFilteriv
LPALEFFECTIV alEffectiv
bool isActive() const
Returns true if sound effect module is active.
void setDirectFilter(SoundFilter *filter)
Sets the direct filter.
uint16_t m_createdSlots
Maximal created effect slots, can be different to MAX_EFFECT_SLOTS.
The Equalizer providing tonal control over four different adjustable frequency ranges.
Definition: soundeffect.h:810
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti
The frequency shifter is a single-sideband modulator, which translates all the component frequencies ...
Definition: soundeffect.h:533
std::vector< SoundEffect * > m_effects
Holds all SoundEffects.
The Auto-wah effect emulates the sound of a wah-wah pedal used with an electric guitar, or a mute on a brass instrument.
Definition: soundeffect.h:732
LPALGETEFFECTIV alGetEffectiv
SoundFilter * createSoundFilter(SoundFilterType type)
Creates SoundFilter of the specific type.
void setFilter(SoundFilter *filter)
Sets the additional sound filter.
Definition: soundeffect.cpp:83
bool isEnabled() const
Return true if the filter is enabled, false otherwise.
Definition: soundfilter.cpp:90
LPALDELETEEFFECTS alDeleteEffects
unsigned short uint16_t
Definition: core.h:39
void deleteSoundEffect(SoundEffect *effect)
Deletes given SoundEffect.
void removeEmitterFromDirectSoundFilter(SoundFilter *filter, SoundEmitter *emitter)
Removes given SoundEmitter from the specific direct SoundFilter.
LPALGETFILTERI alGetFilteri
SoundEffect * createSoundEffectPreset(SoundEffectPreset type)
Creates EaxReverb SoundEffect and loads the specific preset type.
LPALISFILTER alIsFilter
void addEffect(SoundEffect *effect)
Adds effect.
The flanger effect creates a “tearing” or “whooshing” sound.
Definition: soundeffect.h:456
The class for playing audio files.
Definition: soundemitter.h:70
SoundEffectType
Sound effect type.
Definition: soundconfig.h:48
const uint16_t MAX_EFFECT_SLOTS
Definition: soundconfig.h:199
LPALEFFECTI alEffecti
void deactivateEffect(SoundEffect *effect, SoundEmitter *emitter)
Internal function to do the OpenAL calls to deactivate the SoundEffect for the SoundEmitter.
The environmental reverberation effect.
Definition: soundeffect.h:106
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots
ALuint getEffectId() const
Return the OpenAL effect handle.
Definition: soundeffect.cpp:59
LPALGETEFFECTF alGetEffectf
The ring modulator multiplies an input signal by a carrier signal in the time domain, resulting in tremolo or inharmonic effects.
Definition: soundeffect.h:692
The EAX Reverb is similar to Reverb but supports more options.
Definition: soundeffect.h:922
std::queue< ALuint > m_freeSlots
Holds free handles for effect slots.
void activateFilter(SoundFilter *filter, SoundEmitter *emitter)
Internal function to do the OpenAL calls to activate the SoundFilter for the SoundEmitter.
The echo effect generates discrete, delayed instances of the input signal.
Definition: soundeffect.h:395
LPALGETEFFECTI alGetEffecti
void enableSoundEffect(SoundEffect *effect)
Enables given SoundEffect.
SoundFilterType
Sound filter type.
Definition: soundconfig.h:39
uint8_t getEffectNumber(SoundEffect *effect)
Return the number of the given effect.
ALuint m_effectSlots[MAX_EFFECT_SLOTS]
Holds handles for effects.
std::vector< SoundFilter * > m_filters
Holds all SoundFilters.
LPALGETEFFECTFV alGetEffectfv
void setSlotId(ALuint slot)
Sets the OpenAL auxiliary slot handle.
Definition: soundeffect.cpp:63
The pitch shifter applies time-invariant pitch shifting to the input signal, over a one octave range ...
Definition: soundeffect.h:658
LPALEFFECTFV alEffectfv
void addEmitterToSoundEffect(SoundEffect *effect, SoundEmitter *emitter)
Adds given SoundEmitter to the specific SoundEffect.
bool isEnabled() const
Return true if the effect is enabled, false otherwise.
Definition: soundeffect.cpp:79
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti
void loadPreset(const EFXEAXREVERBPROPERTIES &prop)
Load presets into the EAX reverb.
ALuint getFilterId() const
Return the OpenAL filter handle.
Definition: soundfilter.cpp:61
void setEnabled(bool enabled)
Enables or disables the filter.
Definition: soundfilter.cpp:86
std::map< SoundEffectPreset, EFXEAXREVERBPROPERTIES > m_presets
Establishes the relationship between SoundEffectPreset and EFXEAXREVERBPROPERTIES.
SoundFilter * getDirectFilter()
Return the direct filter.
bool isActive() const
Return if the Emitter is active / have an openAl-source.
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv