Limit convolution processing to the output ambisonic order
[openal-soft.git] / al / auxeffectslot.h
blob79373f456b7deb4b1912d483e92e181ad550629a
1 #ifndef AL_AUXEFFECTSLOT_H
2 #define AL_AUXEFFECTSLOT_H
4 #include <atomic>
5 #include <cstddef>
7 #include "AL/al.h"
8 #include "AL/alc.h"
9 #include "AL/efx.h"
11 #include "alcmain.h"
12 #include "almalloc.h"
13 #include "atomic.h"
14 #include "effects/base.h"
15 #include "intrusive_ptr.h"
16 #include "vector.h"
18 struct ALbuffer;
19 struct ALeffect;
20 struct ALeffectslot;
23 using ALeffectslotArray = al::FlexArray<ALeffectslot*>;
26 struct ALeffectslotProps {
27 float Gain;
28 bool AuxSendAuto;
29 ALeffectslot *Target;
31 ALenum Type;
32 EffectProps Props;
34 al::intrusive_ptr<EffectState> State;
35 al::intrusive_ptr<EffectBufferBase> Buffer;
37 std::atomic<ALeffectslotProps*> next;
39 DEF_NEWDEL(ALeffectslotProps)
43 struct ALeffectslot {
44 float Gain{1.0f};
45 bool AuxSendAuto{true};
46 ALeffectslot *Target{nullptr};
47 ALbuffer *Buffer{nullptr};
49 struct {
50 ALenum Type{AL_EFFECT_NULL};
51 EffectProps Props{};
53 al::intrusive_ptr<EffectState> State;
54 al::intrusive_ptr<EffectBufferBase> Buffer;
55 } Effect;
57 std::atomic_flag PropsClean;
59 RefCount ref{0u};
61 struct {
62 std::atomic<ALeffectslotProps*> Update{nullptr};
64 float Gain{1.0f};
65 bool AuxSendAuto{true};
66 ALeffectslot *Target{nullptr};
68 ALenum EffectType{AL_EFFECT_NULL};
69 EffectProps mEffectProps{};
70 EffectState *mEffectState{nullptr};
71 EffectBufferBase *mEffectBuffer{nullptr};
73 float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
74 float DecayTime{0.0f};
75 float DecayLFRatio{0.0f};
76 float DecayHFRatio{0.0f};
77 bool DecayHFLimit{false};
78 float AirAbsorptionGainHF{1.0f};
79 } Params;
81 /* Self ID */
82 ALuint id{};
84 /* Mixing buffer used by the Wet mix. */
85 al::vector<FloatBufferLine, 16> MixBuffer;
87 /* Wet buffer configuration is ACN channel order with N3D scaling.
88 * Consequently, effects that only want to work with mono input can use
89 * channel 0 by itself. Effects that want multichannel can process the
90 * ambisonics signal and make a B-Format source pan.
92 MixParams Wet;
94 ALeffectslot() { PropsClean.test_and_set(std::memory_order_relaxed); }
95 ALeffectslot(const ALeffectslot&) = delete;
96 ALeffectslot& operator=(const ALeffectslot&) = delete;
97 ~ALeffectslot();
99 ALenum init();
100 ALenum initEffect(ALeffect *effect, ALCcontext *context);
101 void updateProps(ALCcontext *context);
103 static ALeffectslotArray *CreatePtrArray(size_t count) noexcept;
105 /* This can be new'd for the context's default effect slot. */
106 DEF_NEWDEL(ALeffectslot)
109 void UpdateAllEffectSlotProps(ALCcontext *context);
111 #endif