Don't apply distance attenuation when the slot's AuxSendAuto is off
[openal-soft.git] / al / filter.h
blob562ec52e2ddfee5e5233b92fa7b3c6189389c71b
1 #ifndef AL_FILTER_H
2 #define AL_FILTER_H
4 #include <array>
5 #include <cstdint>
6 #include <string_view>
7 #include <utility>
8 #include <variant>
10 #include "AL/al.h"
11 #include "AL/alc.h"
12 #include "AL/efx.h"
14 #include "almalloc.h"
15 #include "alnumeric.h"
18 inline constexpr float LowPassFreqRef{5000.0f};
19 inline constexpr float HighPassFreqRef{250.0f};
21 template<typename T>
22 struct FilterTable {
23 static void setParami(struct ALfilter*, ALenum, int);
24 static void setParamiv(struct ALfilter*, ALenum, const int*);
25 static void setParamf(struct ALfilter*, ALenum, float);
26 static void setParamfv(struct ALfilter*, ALenum, const float*);
28 static void getParami(const struct ALfilter*, ALenum, int*);
29 static void getParamiv(const struct ALfilter*, ALenum, int*);
30 static void getParamf(const struct ALfilter*, ALenum, float*);
31 static void getParamfv(const struct ALfilter*, ALenum, float*);
34 struct NullFilterTable : public FilterTable<NullFilterTable> { };
35 struct LowpassFilterTable : public FilterTable<LowpassFilterTable> { };
36 struct HighpassFilterTable : public FilterTable<HighpassFilterTable> { };
37 struct BandpassFilterTable : public FilterTable<BandpassFilterTable> { };
40 struct ALfilter {
41 ALenum type{AL_FILTER_NULL};
43 float Gain{1.0f};
44 float GainHF{1.0f};
45 float HFReference{LowPassFreqRef};
46 float GainLF{1.0f};
47 float LFReference{HighPassFreqRef};
49 using TableTypes = std::variant<NullFilterTable,LowpassFilterTable,HighpassFilterTable,
50 BandpassFilterTable>;
51 TableTypes mTypeVariant;
53 /* Self ID */
54 ALuint id{0};
56 static void SetName(ALCcontext *context, ALuint id, std::string_view name);
58 DISABLE_ALLOC
61 struct FilterSubList {
62 uint64_t FreeMask{~0_u64};
63 gsl::owner<std::array<ALfilter,64>*> Filters{nullptr};
65 FilterSubList() noexcept = default;
66 FilterSubList(const FilterSubList&) = delete;
67 FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
68 { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
69 ~FilterSubList();
71 FilterSubList& operator=(const FilterSubList&) = delete;
72 FilterSubList& operator=(FilterSubList&& rhs) noexcept
73 { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; }
76 #endif