Use function-like macros to call filter and effect vtable methods
[openal-soft.git] / OpenAL32 / Include / alEffect.h
blob95fa035eb7e480df64f003de969beec662639ac2
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 CHORUS_EFFECT,
16 COMPRESSOR_EFFECT,
17 DISTORTION_EFFECT,
18 ECHO_EFFECT,
19 EQUALIZER_EFFECT,
20 FLANGER_EFFECT,
21 MODULATOR_EFFECT,
22 DEDICATED_EFFECT,
24 MAX_EFFECTS
26 extern ALboolean DisabledEffects[MAX_EFFECTS];
28 extern ALfloat ReverbBoost;
30 struct EffectList {
31 const char name[16];
32 int type;
33 ALenum val;
35 #define EFFECTLIST_SIZE 11
36 extern const struct EffectList EffectList[EFFECTLIST_SIZE];
39 struct ALeffectVtable {
40 void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
41 void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
42 void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
43 void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
45 void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
46 void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
47 void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
48 void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
51 #define DEFINE_ALEFFECT_VTABLE(T) \
52 const struct ALeffectVtable T##_vtable = { \
53 T##_setParami, T##_setParamiv, \
54 T##_setParamf, T##_setParamfv, \
55 T##_getParami, T##_getParamiv, \
56 T##_getParamf, T##_getParamfv, \
59 extern const struct ALeffectVtable ALeaxreverb_vtable;
60 extern const struct ALeffectVtable ALreverb_vtable;
61 extern const struct ALeffectVtable ALchorus_vtable;
62 extern const struct ALeffectVtable ALcompressor_vtable;
63 extern const struct ALeffectVtable ALdistortion_vtable;
64 extern const struct ALeffectVtable ALecho_vtable;
65 extern const struct ALeffectVtable ALequalizer_vtable;
66 extern const struct ALeffectVtable ALflanger_vtable;
67 extern const struct ALeffectVtable ALmodulator_vtable;
68 extern const struct ALeffectVtable ALnull_vtable;
69 extern const struct ALeffectVtable ALdedicated_vtable;
72 typedef union ALeffectProps {
73 struct {
74 // Shared Reverb Properties
75 ALfloat Density;
76 ALfloat Diffusion;
77 ALfloat Gain;
78 ALfloat GainHF;
79 ALfloat DecayTime;
80 ALfloat DecayHFRatio;
81 ALfloat ReflectionsGain;
82 ALfloat ReflectionsDelay;
83 ALfloat LateReverbGain;
84 ALfloat LateReverbDelay;
85 ALfloat AirAbsorptionGainHF;
86 ALfloat RoomRolloffFactor;
87 ALboolean DecayHFLimit;
89 // Additional EAX Reverb Properties
90 ALfloat GainLF;
91 ALfloat DecayLFRatio;
92 ALfloat ReflectionsPan[3];
93 ALfloat LateReverbPan[3];
94 ALfloat EchoTime;
95 ALfloat EchoDepth;
96 ALfloat ModulationTime;
97 ALfloat ModulationDepth;
98 ALfloat HFReference;
99 ALfloat LFReference;
100 } Reverb;
102 struct {
103 ALint Waveform;
104 ALint Phase;
105 ALfloat Rate;
106 ALfloat Depth;
107 ALfloat Feedback;
108 ALfloat Delay;
109 } Chorus; /* Also Flanger */
111 struct {
112 ALboolean OnOff;
113 } Compressor;
115 struct {
116 ALfloat Edge;
117 ALfloat Gain;
118 ALfloat LowpassCutoff;
119 ALfloat EQCenter;
120 ALfloat EQBandwidth;
121 } Distortion;
123 struct {
124 ALfloat Delay;
125 ALfloat LRDelay;
127 ALfloat Damping;
128 ALfloat Feedback;
130 ALfloat Spread;
131 } Echo;
133 struct {
134 ALfloat LowCutoff;
135 ALfloat LowGain;
136 ALfloat Mid1Center;
137 ALfloat Mid1Gain;
138 ALfloat Mid1Width;
139 ALfloat Mid2Center;
140 ALfloat Mid2Gain;
141 ALfloat Mid2Width;
142 ALfloat HighCutoff;
143 ALfloat HighGain;
144 } Equalizer;
146 struct {
147 ALfloat Frequency;
148 ALfloat HighPassCutoff;
149 ALint Waveform;
150 } Modulator;
152 struct {
153 ALfloat Gain;
154 } Dedicated;
155 } ALeffectProps;
157 typedef struct ALeffect {
158 // Effect type (AL_EFFECT_NULL, ...)
159 ALenum type;
161 ALeffectProps Props;
163 const struct ALeffectVtable *vtab;
165 /* Self ID */
166 ALuint id;
167 } ALeffect;
168 #define ALeffect_setParami(o, c, p, v) ((o)->vtab->setParami(o, c, p, v))
169 #define ALeffect_setParamf(o, c, p, v) ((o)->vtab->setParamf(o, c, p, v))
170 #define ALeffect_setParamiv(o, c, p, v) ((o)->vtab->setParamiv(o, c, p, v))
171 #define ALeffect_setParamfv(o, c, p, v) ((o)->vtab->setParamfv(o, c, p, v))
172 #define ALeffect_getParami(o, c, p, v) ((o)->vtab->getParami(o, c, p, v))
173 #define ALeffect_getParamf(o, c, p, v) ((o)->vtab->getParamf(o, c, p, v))
174 #define ALeffect_getParamiv(o, c, p, v) ((o)->vtab->getParamiv(o, c, p, v))
175 #define ALeffect_getParamfv(o, c, p, v) ((o)->vtab->getParamfv(o, c, p, v))
177 inline ALboolean IsReverbEffect(ALenum type)
178 { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
180 void InitEffect(ALeffect *effect);
181 void ReleaseALEffects(ALCdevice *device);
183 void LoadReverbPreset(const char *name, ALeffect *effect);
185 #ifdef __cplusplus
187 #endif
189 #endif