Wayverb
filter_structs.h
1 #pragma once
2 
3 #include "core/cl/representation.h"
4 #include "core/cl/traits.h"
5 
6 namespace wayverb {
7 namespace waveguide {
8 
9 constexpr size_t biquad_order{2};
10 constexpr size_t biquad_sections{3};
11 
13 
14 using filt_real = cl_double;
15 
17 
19 template <size_t o>
20 struct alignas(1 << 3) memory final {
21  static constexpr size_t order = o;
22  filt_real array[order]{};
23 };
24 
25 template <size_t D>
26 inline bool operator==(const memory<D>& a, const memory<D>& b) {
27  return std::equal(
28  std::begin(a.array), std::end(a.array), std::begin(b.array));
29 }
30 
31 template <size_t D>
32 inline bool operator!=(const memory<D>& a, const memory<D>& b) {
33  return !(a == b);
34 }
35 
37 
39 template <size_t o>
40 struct alignas(1 << 3) coefficients final {
41  static constexpr auto order = o;
42  filt_real b[order + 1]{};
43  filt_real a[order + 1]{};
44 };
45 
46 template <size_t D>
47 inline bool operator==(const coefficients<D>& a, const coefficients<D>& b) {
48  return std::equal(std::begin(a.a), std::end(a.a), std::begin(b.a)) &&
49  std::equal(std::begin(a.b), std::end(a.b), std::begin(b.b));
50 }
51 
52 template <size_t D>
53 inline bool operator!=(const coefficients<D>& a, const coefficients<D>& b) {
54  return !(a == b);
55 }
56 
58 
60 
62 
64 
67 
69 
71 struct alignas(1 << 3) biquad_memory_array final {
72  memory_biquad array[biquad_sections]{};
73 };
74 
76 
78 struct alignas(1 << 3) biquad_coefficients_array final {
79  coefficients_biquad array[biquad_sections]{};
80 };
81 
82 } // namespace waveguide
83 
84 template <>
85 struct core::cl_representation<waveguide::filt_real> final {
86  static constexpr auto value = R"(
87 typedef double filt_real;
88 )";
89 };
90 
91 template <>
92 struct core::cl_representation<waveguide::memory_biquad> final {
93  static const std::string value;
94 };
95 
96 template <>
97 struct core::cl_representation<waveguide::coefficients_biquad> final {
98  static const std::string value;
99 };
100 
101 template <>
102 struct core::cl_representation<waveguide::memory_canonical> final {
103  static const std::string value;
104 };
105 
106 template <>
107 struct core::cl_representation<waveguide::coefficients_canonical> final {
108  static const std::string value;
109 };
110 
111 template <>
112 struct core::cl_representation<waveguide::biquad_memory_array> final {
113  static constexpr auto value = R"(
114 typedef struct {
115  memory_biquad array[BIQUAD_SECTIONS];
116 } biquad_memory_array;
117 )";
118 };
119 
120 template <>
121 struct core::cl_representation<waveguide::biquad_coefficients_array> final {
122  static constexpr auto value = R"(
123 typedef struct {
124  coefficients_biquad array[BIQUAD_SECTIONS];
125 } biquad_coefficients_array;
126 )";
127 };
128 
129 } // namespace wayverb
Definition: representation.h:7
Several sets of biquad parameters.
Definition: filter_structs.h:78
IIR filter coefficient storage.
Definition: filter_structs.h:40
Definition: capsule_base.h:9
Just an array of filt_real to use as a delay line.
Definition: filter_structs.h:20
Several biquad delay lines in a row.
Definition: filter_structs.h:71