1 #ifndef AL_AUXEFFECTSLOT_H
2 #define AL_AUXEFFECTSLOT_H
11 #include "alc/device.h"
12 #include "alc/effects/base.h"
15 #include "core/effectslot.h"
16 #include "intrusive_ptr.h"
22 #include "eax_eax_call.h"
23 #include "eax_effect.h"
24 #include "eax_fx_slot_index.h"
32 enum class SlotState
: ALenum
{
40 bool AuxSendAuto
{true};
41 ALeffectslot
*Target
{nullptr};
42 ALbuffer
*Buffer
{nullptr};
45 EffectSlotType Type
{EffectSlotType::None
};
48 al::intrusive_ptr
<EffectState
> State
;
51 bool mPropsDirty
{true};
53 SlotState mState
{SlotState::Initial
};
63 ALeffectslot(const ALeffectslot
&) = delete;
64 ALeffectslot
& operator=(const ALeffectslot
&) = delete;
67 ALenum
initEffect(ALenum effectType
, const EffectProps
&effectProps
, ALCcontext
*context
);
68 void updateProps(ALCcontext
*context
);
70 /* This can be new'd for the context's default effect slot. */
71 DEF_NEWDEL(ALeffectslot
)
77 ALCcontext
& al_context
,
78 EaxFxSlotIndexValue index
);
80 const EAX50FXSLOTPROPERTIES
& eax_get_eax_fx_slot() const noexcept
;
84 bool eax_dispatch(const EaxEaxCall
& eax_call
)
85 { return eax_call
.is_get() ? eax_get(eax_call
) : eax_set(eax_call
); }
88 void eax_unlock_legacy() noexcept
;
90 void eax_commit() { eax_apply_deferred(); }
93 ALCcontext
* eax_al_context_
{};
95 EaxFxSlotIndexValue eax_fx_slot_index_
{};
97 EAX50FXSLOTPROPERTIES eax_eax_fx_slot_
{};
99 EaxEffectUPtr eax_effect_
{};
100 bool eax_is_locked_
{};
104 static void eax_fail(
105 const char* message
);
108 GUID
eax_get_eax_default_effect_guid() const noexcept
;
109 long eax_get_eax_default_lock() const noexcept
;
111 void eax_set_eax_fx_slot_defaults();
113 void eax_initialize_eax();
115 void eax_initialize_lock();
118 void eax_initialize_effects();
121 void eax_get_fx_slot_all(
122 const EaxEaxCall
& eax_call
) const;
124 void eax_get_fx_slot(
125 const EaxEaxCall
& eax_call
) const;
129 const EaxEaxCall
& eax_call
);
132 void eax_set_fx_slot_effect(
135 void eax_set_fx_slot_effect();
138 void eax_set_efx_effect_slot_gain();
140 void eax_set_fx_slot_volume();
143 void eax_set_effect_slot_send_auto();
145 void eax_set_fx_slot_flags();
148 void eax_ensure_is_unlocked() const;
151 void eax_validate_fx_slot_effect(
152 const GUID
& eax_effect_id
);
154 void eax_validate_fx_slot_volume(
157 void eax_validate_fx_slot_lock(
160 void eax_validate_fx_slot_flags(
161 unsigned long eax_flags
,
164 void eax_validate_fx_slot_occlusion(
167 void eax_validate_fx_slot_occlusion_lf_ratio(
168 float eax_occlusion_lf_ratio
);
170 void eax_validate_fx_slot_all(
171 const EAX40FXSLOTPROPERTIES
& fx_slot
,
174 void eax_validate_fx_slot_all(
175 const EAX50FXSLOTPROPERTIES
& fx_slot
,
179 void eax_set_fx_slot_effect(
180 const GUID
& eax_effect_id
);
182 void eax_set_fx_slot_volume(
185 void eax_set_fx_slot_lock(
188 void eax_set_fx_slot_flags(
189 unsigned long eax_flags
);
192 bool eax_set_fx_slot_occlusion(
196 bool eax_set_fx_slot_occlusion_lf_ratio(
197 float eax_occlusion_lf_ratio
);
199 void eax_set_fx_slot_all(
200 const EAX40FXSLOTPROPERTIES
& eax_fx_slot
);
203 bool eax_set_fx_slot_all(
204 const EAX50FXSLOTPROPERTIES
& eax_fx_slot
);
207 void eax_set_fx_slot_effect(
208 const EaxEaxCall
& eax_call
);
210 void eax_set_fx_slot_volume(
211 const EaxEaxCall
& eax_call
);
213 void eax_set_fx_slot_lock(
214 const EaxEaxCall
& eax_call
);
216 void eax_set_fx_slot_flags(
217 const EaxEaxCall
& eax_call
);
220 bool eax_set_fx_slot_occlusion(
221 const EaxEaxCall
& eax_call
);
224 bool eax_set_fx_slot_occlusion_lf_ratio(
225 const EaxEaxCall
& eax_call
);
228 bool eax_set_fx_slot_all(
229 const EaxEaxCall
& eax_call
);
231 bool eax_set_fx_slot(
232 const EaxEaxCall
& eax_call
);
234 void eax_apply_deferred();
238 const EaxEaxCall
& eax_call
);
241 void eax_dispatch_effect(
242 const EaxEaxCall
& eax_call
);
245 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_EFFECT, effect)`
246 void eax_set_effect_slot_effect(EaxEffect
&effect
);
248 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, value)`
249 void eax_set_effect_slot_send_auto(bool is_send_auto
);
251 // `alAuxiliaryEffectSlotf(effect_slot, AL_EFFECTSLOT_GAIN, gain)`
252 void eax_set_effect_slot_gain(ALfloat gain
);
257 void operator()(ALeffectslot
*effect_slot
);
258 }; // EaxAlEffectSlotDeleter
262 void UpdateAllEffectSlotProps(ALCcontext
*context
);
266 using EaxAlEffectSlotUPtr
= std::unique_ptr
<ALeffectslot
, ALeffectslot::EaxDeleter
>;
269 EaxAlEffectSlotUPtr
eax_create_al_effect_slot(
270 ALCcontext
& context
);
272 void eax_delete_al_effect_slot(
274 ALeffectslot
& effect_slot
);