Remove another duplicate function
[openal-soft.git] / OpenAL32 / Include / alAuxEffectSlot.h
blob03ee97d6fd60aa99bb4f9496934d0c80775b3124
1 #ifndef _AL_AUXEFFECTSLOT_H_
2 #define _AL_AUXEFFECTSLOT_H_
4 #include "alMain.h"
5 #include "alEffect.h"
7 #include "atomic.h"
8 #include "align.h"
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 struct ALeffectStateVtable;
15 struct ALeffectslot;
17 typedef struct ALeffectState {
18 RefCount Ref;
19 const struct ALeffectStateVtable *vtbl;
21 ALfloat (*OutBuffer)[BUFFERSIZE];
22 ALsizei OutChannels;
23 } ALeffectState;
25 void ALeffectState_Construct(ALeffectState *state);
26 void ALeffectState_Destruct(ALeffectState *state);
28 struct ALeffectStateVtable {
29 void (*const Destruct)(ALeffectState *state);
31 ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device);
32 void (*const update)(ALeffectState *state, const ALCcontext *context, const struct ALeffectslot *slot, const union ALeffectProps *props);
33 void (*const process)(ALeffectState *state, ALsizei samplesToDo, const ALfloat (*restrict samplesIn)[BUFFERSIZE], ALfloat (*restrict samplesOut)[BUFFERSIZE], ALsizei numChannels);
35 void (*const Delete)(void *ptr);
38 /* Small hack to use a pointer-to-array types as a normal argument type.
39 * Shouldn't be used directly.
41 typedef ALfloat ALfloatBUFFERSIZE[BUFFERSIZE];
43 #define DEFINE_ALEFFECTSTATE_VTABLE(T) \
44 DECLARE_THUNK(T, ALeffectState, void, Destruct) \
45 DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
46 DECLARE_THUNK3(T, ALeffectState, void, update, const ALCcontext*, const ALeffectslot*, const ALeffectProps*) \
47 DECLARE_THUNK4(T, ALeffectState, void, process, ALsizei, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALsizei) \
48 static void T##_ALeffectState_Delete(void *ptr) \
49 { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
51 static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
52 T##_ALeffectState_Destruct, \
54 T##_ALeffectState_deviceUpdate, \
55 T##_ALeffectState_update, \
56 T##_ALeffectState_process, \
58 T##_ALeffectState_Delete, \
62 struct EffectStateFactoryVtable;
64 typedef struct EffectStateFactory {
65 const struct EffectStateFactoryVtable *vtab;
66 } EffectStateFactory;
68 struct EffectStateFactoryVtable {
69 ALeffectState *(*const create)(EffectStateFactory *factory);
71 #define EffectStateFactory_create(x) ((x)->vtab->create((x)))
73 #define DEFINE_EFFECTSTATEFACTORY_VTABLE(T) \
74 DECLARE_THUNK(T, EffectStateFactory, ALeffectState*, create) \
76 static const struct EffectStateFactoryVtable T##_EffectStateFactory_vtable = { \
77 T##_EffectStateFactory_create, \
81 #define MAX_EFFECT_CHANNELS (4)
84 struct ALeffectslotArray {
85 ALsizei count;
86 struct ALeffectslot *slot[];
90 struct ALeffectslotProps {
91 ALfloat Gain;
92 ALboolean AuxSendAuto;
94 ALenum Type;
95 ALeffectProps Props;
97 ALeffectState *State;
99 ATOMIC(struct ALeffectslotProps*) next;
103 typedef struct ALeffectslot {
104 ALfloat Gain;
105 ALboolean AuxSendAuto;
107 struct {
108 ALenum Type;
109 ALeffectProps Props;
111 ALeffectState *State;
112 } Effect;
114 ATOMIC_FLAG PropsClean;
116 RefCount ref;
118 ATOMIC(struct ALeffectslotProps*) Update;
120 struct {
121 ALfloat Gain;
122 ALboolean AuxSendAuto;
124 ALenum EffectType;
125 ALeffectProps EffectProps;
126 ALeffectState *EffectState;
128 ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
129 ALfloat DecayTime;
130 ALfloat DecayLFRatio;
131 ALfloat DecayHFRatio;
132 ALboolean DecayHFLimit;
133 ALfloat AirAbsorptionGainHF;
134 } Params;
136 /* Self ID */
137 ALuint id;
139 ALsizei NumChannels;
140 BFChannelConfig ChanMap[MAX_EFFECT_CHANNELS];
141 /* Wet buffer configuration is ACN channel order with N3D scaling:
142 * * Channel 0 is the unattenuated mono signal.
143 * * Channel 1 is OpenAL -X * sqrt(3)
144 * * Channel 2 is OpenAL Y * sqrt(3)
145 * * Channel 3 is OpenAL -Z * sqrt(3)
146 * Consequently, effects that only want to work with mono input can use
147 * channel 0 by itself. Effects that want multichannel can process the
148 * ambisonics signal and make a B-Format source pan for first-order device
149 * output (FOAOut).
151 alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE];
152 } ALeffectslot;
154 ALenum InitEffectSlot(ALeffectslot *slot);
155 void DeinitEffectSlot(ALeffectslot *slot);
156 void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context);
157 void UpdateAllEffectSlotProps(ALCcontext *context);
158 ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
161 EffectStateFactory *NullStateFactory_getFactory(void);
162 EffectStateFactory *ReverbStateFactory_getFactory(void);
163 EffectStateFactory *AutowahStateFactory_getFactory(void);
164 EffectStateFactory *ChorusStateFactory_getFactory(void);
165 EffectStateFactory *CompressorStateFactory_getFactory(void);
166 EffectStateFactory *DistortionStateFactory_getFactory(void);
167 EffectStateFactory *EchoStateFactory_getFactory(void);
168 EffectStateFactory *EqualizerStateFactory_getFactory(void);
169 EffectStateFactory *FlangerStateFactory_getFactory(void);
170 EffectStateFactory *FshifterStateFactory_getFactory(void);
171 EffectStateFactory *ModulatorStateFactory_getFactory(void);
172 EffectStateFactory *PshifterStateFactory_getFactory(void);
174 EffectStateFactory *DedicatedStateFactory_getFactory(void);
177 ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
179 void ALeffectState_DecRef(ALeffectState *state);
181 #ifdef __cplusplus
183 #endif
185 #endif