Don't apply distance attenuation when the slot's AuxSendAuto is off
[openal-soft.git] / al / effect.h
blob842566578988b427f32541f5be176707ff90c3e4
1 #ifndef AL_EFFECT_H
2 #define AL_EFFECT_H
4 #include <array>
5 #include <bitset>
6 #include <cstdint>
7 #include <string_view>
8 #include <utility>
10 #include "AL/al.h"
11 #include "AL/alc.h"
12 #include "AL/efx.h"
14 #include "almalloc.h"
15 #include "alnumeric.h"
16 #include "core/effects/base.h"
17 #include "effects/effects.h"
20 enum {
21 EAXREVERB_EFFECT = 0,
22 REVERB_EFFECT,
23 AUTOWAH_EFFECT,
24 CHORUS_EFFECT,
25 COMPRESSOR_EFFECT,
26 DISTORTION_EFFECT,
27 ECHO_EFFECT,
28 EQUALIZER_EFFECT,
29 FLANGER_EFFECT,
30 FSHIFTER_EFFECT,
31 MODULATOR_EFFECT,
32 PSHIFTER_EFFECT,
33 VMORPHER_EFFECT,
34 DEDICATED_EFFECT,
35 CONVOLUTION_EFFECT,
37 MAX_EFFECTS
39 inline std::bitset<MAX_EFFECTS> DisabledEffects;
41 struct EffectList {
42 const char name[16]; /* NOLINT(*-avoid-c-arrays) */
43 ALuint type;
44 ALenum val;
46 extern const std::array<EffectList,16> gEffectList;
48 using EffectHandlerVariant = std::variant<NullEffectHandler,ReverbEffectHandler,
49 StdReverbEffectHandler,AutowahEffectHandler,ChorusEffectHandler,CompressorEffectHandler,
50 DistortionEffectHandler,EchoEffectHandler,EqualizerEffectHandler,FlangerEffectHandler,
51 FshifterEffectHandler,ModulatorEffectHandler,PshifterEffectHandler,VmorpherEffectHandler,
52 DedicatedDialogEffectHandler,DedicatedLfeEffectHandler,ConvolutionEffectHandler>;
54 struct ALeffect {
55 // Effect type (AL_EFFECT_NULL, ...)
56 ALenum type{AL_EFFECT_NULL};
58 EffectHandlerVariant PropsVariant;
59 EffectProps Props{};
61 /* Self ID */
62 ALuint id{0u};
64 static void SetName(ALCcontext *context, ALuint id, std::string_view name);
66 DISABLE_ALLOC
69 void InitEffect(ALeffect *effect);
71 void LoadReverbPreset(const std::string_view name, ALeffect *effect);
73 bool IsValidEffectType(ALenum type) noexcept;
75 struct EffectSubList {
76 uint64_t FreeMask{~0_u64};
77 gsl::owner<std::array<ALeffect,64>*> Effects{nullptr}; /* 64 */
79 EffectSubList() noexcept = default;
80 EffectSubList(const EffectSubList&) = delete;
81 EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects}
82 { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; }
83 ~EffectSubList();
85 EffectSubList& operator=(const EffectSubList&) = delete;
86 EffectSubList& operator=(EffectSubList&& rhs) noexcept
87 { std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; }
90 #endif