FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
soundeffectmanager.h
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 #ifndef FIFE_SOUNDEFFECTMANAGER_H
23 #define FIFE_SOUNDEFFECTMANAGER_H
24 
25 // Standard C++ library includes
26 #include <queue>
27 #include <map>
28 
29 // Platform specific includes
30 
31 // 3rd party library includes
32 
33 // FIFE includes
34 // These includes are split up in two parts, separated by one empty line
35 // First block: files included from the FIFE root src directory
36 // Second block: files included from the same folder
37 #include "audio/fife_openal.h"
38 #include "audio/soundconfig.h"
39 
40 namespace FIFE {
41 
42  class SoundEffect;
43  class SoundFilter;
44  class SoundEmitter;
45 
47  public:
51 
55 
58  void init(ALCdevice* device);
59 
62  bool isActive() const;
63 
68 
73 
77  void deleteSoundEffect(SoundEffect* effect);
78 
81  void enableSoundEffect(SoundEffect* effect);
82 
85  void disableSoundEffect(SoundEffect* effect);
86 
90  void addEmitterToSoundEffect(SoundEffect* effect, SoundEmitter* emitter);
91 
95 
100 
104 
107  void activateEffect(SoundEffect* effect, SoundEmitter* emitter);
108 
111  void deactivateEffect(SoundEffect* effect, SoundEmitter* emitter);
112 
117 
121  void deleteSoundFilter(SoundFilter* filter);
122 
125  void enableDirectSoundFilter(SoundFilter* filter);
126 
130 
135 
139 
142  void activateFilter(SoundFilter* filter, SoundEmitter* emitter);
143 
146  void deactivateFilter(SoundFilter* filter, SoundEmitter* emitter);
147 
148  private:
150  void createPresets();
152  ALCdevice* m_device;
154  bool m_active;
160  std::queue<ALuint> m_freeSlots;
162  ALint m_maxSlots;
164  std::vector<SoundEffect*> m_effects;
166  typedef std::map<SoundEffect*, std::vector<SoundEmitter*> > SoundEffectEmitterMap;
167  SoundEffectEmitterMap m_effectEmitters;
169  std::vector<SoundFilter*> m_filters;
171  typedef std::map<SoundFilter*, std::vector<SoundEmitter*> > SoundFilterEmitterMap;
172  SoundFilterEmitterMap m_filterdEmitters;
174  typedef std::map<SoundFilter*, std::vector<SoundEffect*> > SoundFilterEffectMap;
175  SoundFilterEffectMap m_filterdEffects;
177  std::map<SoundEffectPreset, EFXEAXREVERBPROPERTIES> m_presets;
178  };
179 }
180 #endif
void enableDirectSoundFilter(SoundFilter *filter)
Enables given direct SoundFilter.
SoundFilterEmitterMap m_filterdEmitters
void removeEmitterFromSoundEffect(SoundEffect *effect, SoundEmitter *emitter)
Removes given SoundEmitter from the specific SoundEffect.
void init(ALCdevice *device)
Initializes the effect system.
void deactivateFilter(SoundFilter *filter, SoundEmitter *emitter)
Internal function to do the OpenAL calls to deactivate the SoundFilter for the SoundEmitter.
SoundEffectPreset
Presets for EAX Reverb.
Definition: soundconfig.h:67
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.
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
void addSoundFilterToSoundEffect(SoundEffect *effect, SoundFilter *filter)
Adds given SoundFilter to the SoundEffect.
void disableSoundEffect(SoundEffect *effect)
Disables given SoundEffect.
void createPresets()
Inital the presets.
SoundEffectEmitterMap m_effectEmitters
SoundFilterEffectMap m_filterdEffects
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.
void disableDirectSoundFilter(SoundFilter *filter)
Disables given SoundFilter.
bool isActive() const
Returns true if sound effect module is active.
uint16_t m_createdSlots
Maximal created effect slots, can be different to MAX_EFFECT_SLOTS.
std::vector< SoundEffect * > m_effects
Holds all SoundEffects.
SoundFilter * createSoundFilter(SoundFilterType type)
Creates SoundFilter of the specific type.
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.
SoundEffect * createSoundEffectPreset(SoundEffectPreset type)
Creates EaxReverb SoundEffect and loads the specific preset type.
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
void deactivateEffect(SoundEffect *effect, SoundEmitter *emitter)
Internal function to do the OpenAL calls to deactivate the SoundEffect for the SoundEmitter.
std::map< SoundEffect *, std::vector< SoundEmitter * > > SoundEffectEmitterMap
Holds SoundEffects together with the added SoundEmitters.
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.
void enableSoundEffect(SoundEffect *effect)
Enables given SoundEffect.
SoundFilterType
Sound filter type.
Definition: soundconfig.h:39
ALuint m_effectSlots[MAX_EFFECT_SLOTS]
Holds handles for effects.
std::vector< SoundFilter * > m_filters
Holds all SoundFilters.
std::map< SoundFilter *, std::vector< SoundEmitter * > > SoundFilterEmitterMap
Holds SoundFilters together with the added SoundEmitters.
void addEmitterToSoundEffect(SoundEffect *effect, SoundEmitter *emitter)
Adds given SoundEmitter to the specific SoundEffect.
std::map< SoundFilter *, std::vector< SoundEffect * > > SoundFilterEffectMap
Holds SoundFilters together with the added SoundEffects.
std::map< SoundEffectPreset, EFXEAXREVERBPROPERTIES > m_presets
Establishes the relationship between SoundEffectPreset and EFXEAXREVERBPROPERTIES.