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 ALCdevice
*device
, 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 #define DEFINE_ALEFFECTSTATE_VTABLE(T) \
39 DECLARE_THUNK(T, ALeffectState, void, Destruct) \
40 DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
41 DECLARE_THUNK3(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*, const ALeffectProps*) \
42 DECLARE_THUNK4(T, ALeffectState, void, process, ALsizei, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALsizei) \
43 static void T##_ALeffectState_Delete(void *ptr) \
44 { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
46 static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
47 T##_ALeffectState_Destruct, \
49 T##_ALeffectState_deviceUpdate, \
50 T##_ALeffectState_update, \
51 T##_ALeffectState_process, \
53 T##_ALeffectState_Delete, \
57 struct ALeffectStateFactoryVtable
;
59 typedef struct ALeffectStateFactory
{
60 const struct ALeffectStateFactoryVtable
*vtbl
;
61 } ALeffectStateFactory
;
63 struct ALeffectStateFactoryVtable
{
64 ALeffectState
*(*const create
)(ALeffectStateFactory
*factory
);
67 #define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
68 DECLARE_THUNK(T, ALeffectStateFactory, ALeffectState*, create) \
70 static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
71 T##_ALeffectStateFactory_create, \
75 #define MAX_EFFECT_CHANNELS (4)
78 struct ALeffectslotArray
{
80 struct ALeffectslot
*slot
[];
84 struct ALeffectslotProps
{
86 ALboolean AuxSendAuto
;
93 ATOMIC(struct ALeffectslotProps
*) next
;
97 typedef struct ALeffectslot
{
99 ALboolean AuxSendAuto
;
105 ALeffectState
*State
;
108 ATOMIC_FLAG PropsClean
;
112 ATOMIC(struct ALeffectslotProps
*) Update
;
113 ATOMIC(struct ALeffectslotProps
*) FreeList
;
117 ALboolean AuxSendAuto
;
120 ALeffectState
*EffectState
;
122 ALfloat RoomRolloff
; /* Added to the source's room rolloff, not multiplied. */
124 ALfloat DecayHFRatio
;
125 ALboolean DecayHFLimit
;
126 ALfloat AirAbsorptionGainHF
;
133 BFChannelConfig ChanMap
[MAX_EFFECT_CHANNELS
];
134 /* Wet buffer configuration is ACN channel order with N3D scaling:
135 * * Channel 0 is the unattenuated mono signal.
136 * * Channel 1 is OpenAL -X
137 * * Channel 2 is OpenAL Y
138 * * Channel 3 is OpenAL -Z
139 * Consequently, effects that only want to work with mono input can use
140 * channel 0 by itself. Effects that want multichannel can process the
141 * ambisonics signal and make a B-Format pan (ComputeFirstOrderGains) for
142 * first-order device output (FOAOut).
144 alignas(16) ALfloat WetBuffer
[MAX_EFFECT_CHANNELS
][BUFFERSIZE
];
147 inline void LockEffectSlotsRead(ALCcontext
*context
)
148 { LockUIntMapRead(&context
->EffectSlotMap
); }
149 inline void UnlockEffectSlotsRead(ALCcontext
*context
)
150 { UnlockUIntMapRead(&context
->EffectSlotMap
); }
151 inline void LockEffectSlotsWrite(ALCcontext
*context
)
152 { LockUIntMapWrite(&context
->EffectSlotMap
); }
153 inline void UnlockEffectSlotsWrite(ALCcontext
*context
)
154 { UnlockUIntMapWrite(&context
->EffectSlotMap
); }
156 inline struct ALeffectslot
*LookupEffectSlot(ALCcontext
*context
, ALuint id
)
157 { return (struct ALeffectslot
*)LookupUIntMapKeyNoLock(&context
->EffectSlotMap
, id
); }
158 inline struct ALeffectslot
*RemoveEffectSlot(ALCcontext
*context
, ALuint id
)
159 { return (struct ALeffectslot
*)RemoveUIntMapKeyNoLock(&context
->EffectSlotMap
, id
); }
161 ALenum
InitEffectSlot(ALeffectslot
*slot
);
162 void DeinitEffectSlot(ALeffectslot
*slot
);
163 void UpdateEffectSlotProps(ALeffectslot
*slot
);
164 void UpdateAllEffectSlotProps(ALCcontext
*context
);
165 ALvoid
ReleaseALAuxiliaryEffectSlots(ALCcontext
*Context
);
168 ALeffectStateFactory
*ALnullStateFactory_getFactory(void);
169 ALeffectStateFactory
*ALreverbStateFactory_getFactory(void);
170 ALeffectStateFactory
*ALchorusStateFactory_getFactory(void);
171 ALeffectStateFactory
*ALcompressorStateFactory_getFactory(void);
172 ALeffectStateFactory
*ALdistortionStateFactory_getFactory(void);
173 ALeffectStateFactory
*ALechoStateFactory_getFactory(void);
174 ALeffectStateFactory
*ALequalizerStateFactory_getFactory(void);
175 ALeffectStateFactory
*ALflangerStateFactory_getFactory(void);
176 ALeffectStateFactory
*ALmodulatorStateFactory_getFactory(void);
178 ALeffectStateFactory
*ALdedicatedStateFactory_getFactory(void);
181 ALenum
InitializeEffect(ALCdevice
*Device
, ALeffectslot
*EffectSlot
, ALeffect
*effect
);
183 void InitEffectFactoryMap(void);
184 void DeinitEffectFactoryMap(void);