Recogmize jack64 for finding the JACK library name
[openal-soft.git] / al / filter.h
blobd5b20de2bb32bee370bd14313e04a69a8838a96f
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*);
33 private:
34 FilterTable() = default;
35 friend T;
38 struct NullFilterTable : public FilterTable<NullFilterTable> { };
39 struct LowpassFilterTable : public FilterTable<LowpassFilterTable> { };
40 struct HighpassFilterTable : public FilterTable<HighpassFilterTable> { };
41 struct BandpassFilterTable : public FilterTable<BandpassFilterTable> { };
44 struct ALfilter {
45 ALenum type{AL_FILTER_NULL};
47 float Gain{1.0f};
48 float GainHF{1.0f};
49 float HFReference{LowPassFreqRef};
50 float GainLF{1.0f};
51 float LFReference{HighPassFreqRef};
53 using TableTypes = std::variant<NullFilterTable,LowpassFilterTable,HighpassFilterTable,
54 BandpassFilterTable>;
55 TableTypes mTypeVariant;
57 /* Self ID */
58 ALuint id{0};
60 static void SetName(ALCcontext *context, ALuint id, std::string_view name);
62 DISABLE_ALLOC
65 struct FilterSubList {
66 uint64_t FreeMask{~0_u64};
67 gsl::owner<std::array<ALfilter,64>*> Filters{nullptr};
69 FilterSubList() noexcept = default;
70 FilterSubList(const FilterSubList&) = delete;
71 FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
72 { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
73 ~FilterSubList();
75 FilterSubList& operator=(const FilterSubList&) = delete;
76 FilterSubList& operator=(FilterSubList&& rhs) noexcept
77 { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; }
80 #endif