Prepare the new driver in a local variable
[openal-soft.git] / OpenAL32 / Include / alEffect.h
blob80f029a9cb6d8333d39f9c36923ecb36c8389f86
1 #ifndef _AL_EFFECT_H_
2 #define _AL_EFFECT_H_
4 #include "alMain.h"
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 struct ALeffect;
12 enum {
13 AL__EAXREVERB = 0,
14 AL__REVERB,
15 AL__CHORUS,
16 AL__COMPRESSOR,
17 AL__DISTORTION,
18 AL__ECHO,
19 AL__EQUALIZER,
20 AL__FLANGER,
21 AL__MODULATOR,
22 AL__DEDICATED,
24 MAX_EFFECTS
26 extern ALboolean DisabledEffects[MAX_EFFECTS];
28 extern ALfloat ReverbBoost;
29 extern ALboolean EmulateEAXReverb;
31 struct ALeffectVtable {
32 void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
33 void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
34 void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
35 void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
37 void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
38 void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
39 void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
40 void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
43 #define DEFINE_ALEFFECT_VTABLE(T) \
44 const struct ALeffectVtable T##_vtable = { \
45 T##_setParami, T##_setParamiv, \
46 T##_setParamf, T##_setParamfv, \
47 T##_getParami, T##_getParamiv, \
48 T##_getParamf, T##_getParamfv, \
51 extern const struct ALeffectVtable ALeaxreverb_vtable;
52 extern const struct ALeffectVtable ALreverb_vtable;
53 extern const struct ALeffectVtable ALchorus_vtable;
54 extern const struct ALeffectVtable ALcompressor_vtable;
55 extern const struct ALeffectVtable ALdistortion_vtable;
56 extern const struct ALeffectVtable ALecho_vtable;
57 extern const struct ALeffectVtable ALequalizer_vtable;
58 extern const struct ALeffectVtable ALflanger_vtable;
59 extern const struct ALeffectVtable ALmodulator_vtable;
60 extern const struct ALeffectVtable ALnull_vtable;
61 extern const struct ALeffectVtable ALdedicated_vtable;
64 typedef union ALeffectProps {
65 struct {
66 // Shared Reverb Properties
67 ALfloat Density;
68 ALfloat Diffusion;
69 ALfloat Gain;
70 ALfloat GainHF;
71 ALfloat DecayTime;
72 ALfloat DecayHFRatio;
73 ALfloat ReflectionsGain;
74 ALfloat ReflectionsDelay;
75 ALfloat LateReverbGain;
76 ALfloat LateReverbDelay;
77 ALfloat AirAbsorptionGainHF;
78 ALfloat RoomRolloffFactor;
79 ALboolean DecayHFLimit;
81 // Additional EAX Reverb Properties
82 ALfloat GainLF;
83 ALfloat DecayLFRatio;
84 ALfloat ReflectionsPan[3];
85 ALfloat LateReverbPan[3];
86 ALfloat EchoTime;
87 ALfloat EchoDepth;
88 ALfloat ModulationTime;
89 ALfloat ModulationDepth;
90 ALfloat HFReference;
91 ALfloat LFReference;
92 } Reverb;
94 struct {
95 ALint Waveform;
96 ALint Phase;
97 ALfloat Rate;
98 ALfloat Depth;
99 ALfloat Feedback;
100 ALfloat Delay;
101 } Chorus;
103 struct {
104 ALboolean OnOff;
105 } Compressor;
107 struct {
108 ALfloat Edge;
109 ALfloat Gain;
110 ALfloat LowpassCutoff;
111 ALfloat EQCenter;
112 ALfloat EQBandwidth;
113 } Distortion;
115 struct {
116 ALfloat Delay;
117 ALfloat LRDelay;
119 ALfloat Damping;
120 ALfloat Feedback;
122 ALfloat Spread;
123 } Echo;
125 struct {
126 ALfloat LowCutoff;
127 ALfloat LowGain;
128 ALfloat Mid1Center;
129 ALfloat Mid1Gain;
130 ALfloat Mid1Width;
131 ALfloat Mid2Center;
132 ALfloat Mid2Gain;
133 ALfloat Mid2Width;
134 ALfloat HighCutoff;
135 ALfloat HighGain;
136 } Equalizer;
138 struct {
139 ALint Waveform;
140 ALint Phase;
141 ALfloat Rate;
142 ALfloat Depth;
143 ALfloat Feedback;
144 ALfloat Delay;
145 } Flanger;
147 struct {
148 ALfloat Frequency;
149 ALfloat HighPassCutoff;
150 ALint Waveform;
151 } Modulator;
153 struct {
154 ALfloat Gain;
155 } Dedicated;
156 } ALeffectProps;
158 typedef struct ALeffect {
159 // Effect type (AL_EFFECT_NULL, ...)
160 ALenum type;
162 ALeffectProps Props;
164 const struct ALeffectVtable *vtbl;
166 /* Self ID */
167 ALuint id;
168 } ALeffect;
170 inline void LockEffectsRead(ALCdevice *device)
171 { LockUIntMapRead(&device->EffectMap); }
172 inline void UnlockEffectsRead(ALCdevice *device)
173 { UnlockUIntMapRead(&device->EffectMap); }
174 inline void LockEffectsWrite(ALCdevice *device)
175 { LockUIntMapWrite(&device->EffectMap); }
176 inline void UnlockEffectsWrite(ALCdevice *device)
177 { UnlockUIntMapWrite(&device->EffectMap); }
179 inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
180 { return (struct ALeffect*)LookupUIntMapKeyNoLock(&device->EffectMap, id); }
181 inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
182 { return (struct ALeffect*)RemoveUIntMapKeyNoLock(&device->EffectMap, id); }
184 inline ALboolean IsReverbEffect(ALenum type)
185 { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
187 ALenum InitEffect(ALeffect *effect);
188 ALvoid ReleaseALEffects(ALCdevice *device);
190 ALvoid LoadReverbPreset(const char *name, ALeffect *effect);
192 #ifdef __cplusplus
194 #endif
196 #endif