1 #ifndef _AL_AUXEFFECTSLOT_H_
2 #define _AL_AUXEFFECTSLOT_H_
14 struct ALeffectStateVtable
;
17 typedef struct ALeffectState
{
19 const struct ALeffectStateVtable
*vtbl
;
21 ALfloat (*OutBuffer
)[BUFFERSIZE
];
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 ALeffectStateFactoryVtable
;
64 typedef struct ALeffectStateFactory
{
65 const struct ALeffectStateFactoryVtable
*vtbl
;
66 } ALeffectStateFactory
;
68 struct ALeffectStateFactoryVtable
{
69 ALeffectState
*(*const create
)(ALeffectStateFactory
*factory
);
72 #define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
73 DECLARE_THUNK(T, ALeffectStateFactory, ALeffectState*, create) \
75 static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
76 T##_ALeffectStateFactory_create, \
80 #define MAX_EFFECT_CHANNELS (4)
83 struct ALeffectslotArray
{
85 struct ALeffectslot
*slot
[];
89 struct ALeffectslotProps
{
91 ALboolean AuxSendAuto
;
98 ATOMIC(struct ALeffectslotProps
*) next
;
102 typedef struct ALeffectslot
{
104 ALboolean AuxSendAuto
;
110 ALeffectState
*State
;
113 ATOMIC_FLAG PropsClean
;
117 ATOMIC(struct ALeffectslotProps
*) Update
;
121 ALboolean AuxSendAuto
;
124 ALeffectProps EffectProps
;
125 ALeffectState
*EffectState
;
127 ALfloat RoomRolloff
; /* Added to the source's room rolloff, not multiplied. */
129 ALfloat DecayHFRatio
;
130 ALboolean DecayHFLimit
;
131 ALfloat AirAbsorptionGainHF
;
138 BFChannelConfig ChanMap
[MAX_EFFECT_CHANNELS
];
139 /* Wet buffer configuration is ACN channel order with N3D scaling:
140 * * Channel 0 is the unattenuated mono signal.
141 * * Channel 1 is OpenAL -X
142 * * Channel 2 is OpenAL Y
143 * * Channel 3 is OpenAL -Z
144 * Consequently, effects that only want to work with mono input can use
145 * channel 0 by itself. Effects that want multichannel can process the
146 * ambisonics signal and make a B-Format pan (ComputeFirstOrderGains) for
147 * first-order device output (FOAOut).
149 alignas(16) ALfloat WetBuffer
[MAX_EFFECT_CHANNELS
][BUFFERSIZE
];
152 inline void LockEffectSlotsRead(ALCcontext
*context
)
153 { LockUIntMapRead(&context
->EffectSlotMap
); }
154 inline void UnlockEffectSlotsRead(ALCcontext
*context
)
155 { UnlockUIntMapRead(&context
->EffectSlotMap
); }
156 inline void LockEffectSlotsWrite(ALCcontext
*context
)
157 { LockUIntMapWrite(&context
->EffectSlotMap
); }
158 inline void UnlockEffectSlotsWrite(ALCcontext
*context
)
159 { UnlockUIntMapWrite(&context
->EffectSlotMap
); }
161 inline struct ALeffectslot
*LookupEffectSlot(ALCcontext
*context
, ALuint id
)
162 { return (struct ALeffectslot
*)LookupUIntMapKeyNoLock(&context
->EffectSlotMap
, id
); }
163 inline struct ALeffectslot
*RemoveEffectSlot(ALCcontext
*context
, ALuint id
)
164 { return (struct ALeffectslot
*)RemoveUIntMapKeyNoLock(&context
->EffectSlotMap
, id
); }
166 ALenum
InitEffectSlot(ALeffectslot
*slot
);
167 void DeinitEffectSlot(ALeffectslot
*slot
);
168 void UpdateEffectSlotProps(ALeffectslot
*slot
, ALCcontext
*context
);
169 void UpdateAllEffectSlotProps(ALCcontext
*context
);
170 ALvoid
ReleaseALAuxiliaryEffectSlots(ALCcontext
*Context
);
173 ALeffectStateFactory
*ALnullStateFactory_getFactory(void);
174 ALeffectStateFactory
*ALreverbStateFactory_getFactory(void);
175 ALeffectStateFactory
*ALchorusStateFactory_getFactory(void);
176 ALeffectStateFactory
*ALcompressorStateFactory_getFactory(void);
177 ALeffectStateFactory
*ALdistortionStateFactory_getFactory(void);
178 ALeffectStateFactory
*ALechoStateFactory_getFactory(void);
179 ALeffectStateFactory
*ALequalizerStateFactory_getFactory(void);
180 ALeffectStateFactory
*ALflangerStateFactory_getFactory(void);
181 ALeffectStateFactory
*ALmodulatorStateFactory_getFactory(void);
183 ALeffectStateFactory
*ALdedicatedStateFactory_getFactory(void);
186 ALenum
InitializeEffect(ALCcontext
*Context
, ALeffectslot
*EffectSlot
, ALeffect
*effect
);
188 void InitEffectFactoryMap(void);
189 void DeinitEffectFactoryMap(void);
191 void ALeffectState_DecRef(ALeffectState
*state
);