1 #ifndef _AL_AUXEFFECTSLOT_H_
2 #define _AL_AUXEFFECTSLOT_H_
13 struct ALeffectStateVtable
;
16 typedef struct ALeffectState
{
17 const struct ALeffectStateVtable
*vtbl
;
19 ALfloat (*OutBuffer
)[BUFFERSIZE
];
23 void ALeffectState_Destruct(ALeffectState
*state
);
25 struct ALeffectStateVtable
{
26 void (*const Destruct
)(ALeffectState
*state
);
28 ALboolean (*const deviceUpdate
)(ALeffectState
*state
, ALCdevice
*device
);
29 void (*const update
)(ALeffectState
*state
, const ALCdevice
*device
, const struct ALeffectslot
*slot
, const union ALeffectProps
*props
);
30 void (*const process
)(ALeffectState
*state
, ALuint samplesToDo
, const ALfloat (*restrict samplesIn
)[BUFFERSIZE
], ALfloat (*restrict samplesOut
)[BUFFERSIZE
], ALuint numChannels
);
32 void (*const Delete
)(void *ptr
);
35 #define DEFINE_ALEFFECTSTATE_VTABLE(T) \
36 DECLARE_THUNK(T, ALeffectState, void, Destruct) \
37 DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
38 DECLARE_THUNK3(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*, const ALeffectProps*) \
39 DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
40 static void T##_ALeffectState_Delete(void *ptr) \
41 { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
43 static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
44 T##_ALeffectState_Destruct, \
46 T##_ALeffectState_deviceUpdate, \
47 T##_ALeffectState_update, \
48 T##_ALeffectState_process, \
50 T##_ALeffectState_Delete, \
54 struct ALeffectStateFactoryVtable
;
56 typedef struct ALeffectStateFactory
{
57 const struct ALeffectStateFactoryVtable
*vtbl
;
58 } ALeffectStateFactory
;
60 struct ALeffectStateFactoryVtable
{
61 ALeffectState
*(*const create
)(ALeffectStateFactory
*factory
);
64 #define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
65 DECLARE_THUNK(T, ALeffectStateFactory, ALeffectState*, create) \
67 static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
68 T##_ALeffectStateFactory_create, \
72 #define MAX_EFFECT_CHANNELS (4)
75 struct ALeffectslotProps
{
77 ATOMIC(ALboolean
) AuxSendAuto
;
82 ATOMIC(ALeffectState
*) State
;
84 ATOMIC(struct ALeffectslotProps
*) next
;
88 typedef struct ALeffectslot
{
89 volatile ALfloat Gain
;
90 volatile ALboolean AuxSendAuto
;
101 ATOMIC(struct ALeffectslotProps
*) Update
;
102 ATOMIC(struct ALeffectslotProps
*) FreeList
;
106 ALboolean AuxSendAuto
;
109 ALeffectState
*EffectState
;
111 ALfloat RoomRolloff
; /* Added to the source's room rolloff, not multiplied. */
113 ALfloat AirAbsorptionGainHF
;
120 BFChannelConfig ChanMap
[MAX_EFFECT_CHANNELS
];
121 /* Wet buffer configuration is ACN channel order with N3D scaling:
122 * * Channel 0 is the unattenuated mono signal.
123 * * Channel 1 is OpenAL -X
124 * * Channel 2 is OpenAL Y
125 * * Channel 3 is OpenAL -Z
126 * Consequently, effects that only want to work with mono input can use
127 * channel 0 by itself. Effects that want multichannel can process the
128 * ambisonics signal and make a B-Format pan (ComputeFirstOrderGains) for
129 * first-order device output (FOAOut).
131 alignas(16) ALfloat WetBuffer
[MAX_EFFECT_CHANNELS
][BUFFERSIZE
];
133 ATOMIC(struct ALeffectslot
*) next
;
136 inline struct ALeffectslot
*LookupEffectSlot(ALCcontext
*context
, ALuint id
)
137 { return (struct ALeffectslot
*)LookupUIntMapKey(&context
->EffectSlotMap
, id
); }
138 inline struct ALeffectslot
*RemoveEffectSlot(ALCcontext
*context
, ALuint id
)
139 { return (struct ALeffectslot
*)RemoveUIntMapKey(&context
->EffectSlotMap
, id
); }
141 ALenum
InitEffectSlot(ALeffectslot
*slot
);
142 void DeinitEffectSlot(ALeffectslot
*slot
);
143 void UpdateEffectSlotProps(ALeffectslot
*slot
);
144 ALvoid
ReleaseALAuxiliaryEffectSlots(ALCcontext
*Context
);
147 ALeffectStateFactory
*ALnullStateFactory_getFactory(void);
148 ALeffectStateFactory
*ALreverbStateFactory_getFactory(void);
149 ALeffectStateFactory
*ALautowahStateFactory_getFactory(void);
150 ALeffectStateFactory
*ALchorusStateFactory_getFactory(void);
151 ALeffectStateFactory
*ALcompressorStateFactory_getFactory(void);
152 ALeffectStateFactory
*ALdistortionStateFactory_getFactory(void);
153 ALeffectStateFactory
*ALechoStateFactory_getFactory(void);
154 ALeffectStateFactory
*ALequalizerStateFactory_getFactory(void);
155 ALeffectStateFactory
*ALflangerStateFactory_getFactory(void);
156 ALeffectStateFactory
*ALmodulatorStateFactory_getFactory(void);
158 ALeffectStateFactory
*ALdedicatedStateFactory_getFactory(void);
161 ALenum
InitializeEffect(ALCdevice
*Device
, ALeffectslot
*EffectSlot
, ALeffect
*effect
);
163 void InitEffectFactoryMap(void);
164 void DeinitEffectFactoryMap(void);