Correctly apply reverb coefficient fading over the entire fade length
[openal-soft.git] / OpenAL32 / Include / alEffect.h
blob7b849c0ce8ea58ebdc1b6d99c24f807cb25878e0
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 EAXREVERB_EFFECT = 0,
14 REVERB_EFFECT,
15 AUTOWAH_EFFECT,
16 CHORUS_EFFECT,
17 COMPRESSOR_EFFECT,
18 DISTORTION_EFFECT,
19 ECHO_EFFECT,
20 EQUALIZER_EFFECT,
21 FLANGER_EFFECT,
22 FSHIFTER_EFFECT,
23 MODULATOR_EFFECT,
24 PSHIFTER_EFFECT,
25 DEDICATED_EFFECT,
27 MAX_EFFECTS
29 extern ALboolean DisabledEffects[MAX_EFFECTS];
31 extern ALfloat ReverbBoost;
33 struct EffectList {
34 const char name[16];
35 int type;
36 ALenum val;
38 #define EFFECTLIST_SIZE 14
39 extern const struct EffectList EffectList[EFFECTLIST_SIZE];
42 struct ALeffectVtable {
43 void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
44 void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
45 void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
46 void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
48 void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
49 void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
50 void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
51 void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
54 #define DEFINE_ALEFFECT_VTABLE(T) \
55 const struct ALeffectVtable T##_vtable = { \
56 T##_setParami, T##_setParamiv, \
57 T##_setParamf, T##_setParamfv, \
58 T##_getParami, T##_getParamiv, \
59 T##_getParamf, T##_getParamfv, \
62 extern const struct ALeffectVtable ALeaxreverb_vtable;
63 extern const struct ALeffectVtable ALreverb_vtable;
64 extern const struct ALeffectVtable ALautowah_vtable;
65 extern const struct ALeffectVtable ALchorus_vtable;
66 extern const struct ALeffectVtable ALcompressor_vtable;
67 extern const struct ALeffectVtable ALdistortion_vtable;
68 extern const struct ALeffectVtable ALecho_vtable;
69 extern const struct ALeffectVtable ALequalizer_vtable;
70 extern const struct ALeffectVtable ALflanger_vtable;
71 extern const struct ALeffectVtable ALfshifter_vtable;
72 extern const struct ALeffectVtable ALmodulator_vtable;
73 extern const struct ALeffectVtable ALnull_vtable;
74 extern const struct ALeffectVtable ALpshifter_vtable;
75 extern const struct ALeffectVtable ALdedicated_vtable;
78 typedef union ALeffectProps {
79 struct {
80 // Shared Reverb Properties
81 ALfloat Density;
82 ALfloat Diffusion;
83 ALfloat Gain;
84 ALfloat GainHF;
85 ALfloat DecayTime;
86 ALfloat DecayHFRatio;
87 ALfloat ReflectionsGain;
88 ALfloat ReflectionsDelay;
89 ALfloat LateReverbGain;
90 ALfloat LateReverbDelay;
91 ALfloat AirAbsorptionGainHF;
92 ALfloat RoomRolloffFactor;
93 ALboolean DecayHFLimit;
95 // Additional EAX Reverb Properties
96 ALfloat GainLF;
97 ALfloat DecayLFRatio;
98 ALfloat ReflectionsPan[3];
99 ALfloat LateReverbPan[3];
100 ALfloat EchoTime;
101 ALfloat EchoDepth;
102 ALfloat ModulationTime;
103 ALfloat ModulationDepth;
104 ALfloat HFReference;
105 ALfloat LFReference;
106 } Reverb;
108 struct {
109 ALfloat AttackTime;
110 ALfloat ReleaseTime;
111 ALfloat Resonance;
112 ALfloat PeakGain;
113 } Autowah;
115 struct {
116 ALint Waveform;
117 ALint Phase;
118 ALfloat Rate;
119 ALfloat Depth;
120 ALfloat Feedback;
121 ALfloat Delay;
122 } Chorus; /* Also Flanger */
124 struct {
125 ALboolean OnOff;
126 } Compressor;
128 struct {
129 ALfloat Edge;
130 ALfloat Gain;
131 ALfloat LowpassCutoff;
132 ALfloat EQCenter;
133 ALfloat EQBandwidth;
134 } Distortion;
136 struct {
137 ALfloat Delay;
138 ALfloat LRDelay;
140 ALfloat Damping;
141 ALfloat Feedback;
143 ALfloat Spread;
144 } Echo;
146 struct {
147 ALfloat LowCutoff;
148 ALfloat LowGain;
149 ALfloat Mid1Center;
150 ALfloat Mid1Gain;
151 ALfloat Mid1Width;
152 ALfloat Mid2Center;
153 ALfloat Mid2Gain;
154 ALfloat Mid2Width;
155 ALfloat HighCutoff;
156 ALfloat HighGain;
157 } Equalizer;
159 struct {
160 ALfloat Frequency;
161 ALint LeftDirection;
162 ALint RightDirection;
163 } Fshifter;
165 struct {
166 ALfloat Frequency;
167 ALfloat HighPassCutoff;
168 ALint Waveform;
169 } Modulator;
171 struct {
172 ALint CoarseTune;
173 ALint FineTune;
174 } Pshifter;
176 struct {
177 ALfloat Gain;
178 } Dedicated;
179 } ALeffectProps;
181 typedef struct ALeffect {
182 // Effect type (AL_EFFECT_NULL, ...)
183 ALenum type;
185 ALeffectProps Props;
187 const struct ALeffectVtable *vtab;
189 /* Self ID */
190 ALuint id;
191 } ALeffect;
192 #define ALeffect_setParami(o, c, p, v) ((o)->vtab->setParami(o, c, p, v))
193 #define ALeffect_setParamf(o, c, p, v) ((o)->vtab->setParamf(o, c, p, v))
194 #define ALeffect_setParamiv(o, c, p, v) ((o)->vtab->setParamiv(o, c, p, v))
195 #define ALeffect_setParamfv(o, c, p, v) ((o)->vtab->setParamfv(o, c, p, v))
196 #define ALeffect_getParami(o, c, p, v) ((o)->vtab->getParami(o, c, p, v))
197 #define ALeffect_getParamf(o, c, p, v) ((o)->vtab->getParamf(o, c, p, v))
198 #define ALeffect_getParamiv(o, c, p, v) ((o)->vtab->getParamiv(o, c, p, v))
199 #define ALeffect_getParamfv(o, c, p, v) ((o)->vtab->getParamfv(o, c, p, v))
201 inline ALboolean IsReverbEffect(ALenum type)
202 { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
204 void InitEffect(ALeffect *effect);
205 void ReleaseALEffects(ALCdevice *device);
207 void LoadReverbPreset(const char *name, ALeffect *effect);
209 #ifdef __cplusplus
211 #endif
213 #endif