11template <
class T =
float>
44 const AH::Array<T, 3> &
a)
45 :
b(
b /
a[0]),
a(-
a.template slice<1, 2>() /
a[0]) {}
51 const AH::Array<T, 3> &
a, T gain)
52 :
b(
b * gain /
a[0]),
a(-
a.template slice<1, 2>() /
a[0]) {}
58 template <
bool Enable = true>
59 static std::enable_if_t<std::is_floating_point<T>::value && Enable, T>
60 update(T input, AH::Array<T, 2> &
x, AH::Array<T, 2> &
y,
61 const AH::Array<T, 3> &
b,
const AH::Array<T, 2> &
a) {
63 acc = std::fma(
x[0],
b[1], acc);
64 acc = std::fma(
x[1],
b[2], acc);
65 acc = std::fma(
y[0],
a[0], acc);
66 acc = std::fma(
y[1],
a[1], acc);
74 template <
bool Enable = true>
75 static std::enable_if_t<!std::is_floating_point<T>::value && Enable, T>
76 update(T input, AH::Array<T, 2> &
x, AH::Array<T, 2> &
y,
77 const AH::Array<T, 3> &
b,
const AH::Array<T, 2> &
a) {
79 acc =
x[0] *
b[1] + acc;
80 acc =
x[1] *
b[2] + acc;
81 acc =
y[0] *
a[0] + acc;
82 acc =
y[1] *
a[1] + acc;
101 AH::Array<T, 2>
x = {{}};
102 AH::Array<T, 2>
y = {{}};
103 AH::Array<T, 3>
b = {{}};
104 AH::Array<T, 2>
a = {{}};
129 const AH::Array<T, 3> &
a)
130 :
b(
b),
a(-
a.template slice<1, 2>()),
a0(
a[0]) {}
136 const AH::Array<T, 3> &
a, T gain)
137 :
b(
b * gain),
a(-
a.template slice<1, 2>()),
a0(
a[0]) {}
143 template <
bool Enable = true>
144 static std::enable_if_t<std::is_floating_point<T>::value && Enable, T>
145 update(T input, AH::Array<T, 2> &
x, AH::Array<T, 2> &
y,
146 const AH::Array<T, 3> &
b,
const AH::Array<T, 2> &
a, T
a0) {
147 T acc = input *
b[0];
148 acc = std::fma(
x[0],
b[1], acc);
149 acc = std::fma(
x[1],
b[2], acc);
150 acc = std::fma(
y[0],
a[0], acc);
151 acc = std::fma(
y[1],
a[1], acc);
159 template <
bool Enable = true>
160 static std::enable_if_t<!std::is_floating_point<T>::value && Enable, T>
161 update(T input, AH::Array<T, 2> &
x, AH::Array<T, 2> &
y,
162 const AH::Array<T, 3> &
b,
const AH::Array<T, 2> &
a, T
a0) {
163 T acc = input *
b[0];
164 acc =
x[0] *
b[1] + acc;
165 acc =
x[1] *
b[2] + acc;
166 acc =
y[0] *
a[0] + acc;
167 acc =
y[1] *
a[1] + acc;
186 AH::Array<T, 2>
x = {{}};
187 AH::Array<T, 2>
y = {{}};
188 AH::Array<T, 3>
b = {{}};
189 AH::Array<T, 2>
a = {{}};
199 typename std::conditional<std::is_floating_point<T>::value,
220template <
class T =
float>
242 const AH::Array<T, 3> &a_coefficients)
267 const AH::Array<T, 3> &a_coefficients, T gain)
316 const AH::Array<T, 3> &
a)
317 :
b(
b /
a[0]),
a(-
a.template slice<1, 2>() /
a[0]) {}
323 const AH::Array<T, 3> &
a, T gain)
324 :
b(
b * gain /
a[0]),
a(-
a.template slice<1, 2>() /
a[0]) {}
330 template <
bool Enable = true>
331 static std::enable_if_t<std::is_floating_point<T>::value && Enable, T>
332 update(T input, AH::Array<T, 2> &
w,
const AH::Array<T, 3> &
b,
333 const AH::Array<T, 2> &
a) {
334 input = std::fma(
a[0],
w[0], input);
335 input = std::fma(
a[1],
w[1], input);
336 T result =
b[0] * input;
337 result = std::fma(
b[1],
w[0], result);
338 result = std::fma(
b[2],
w[1], result);
344 template <
bool Enable = true>
345 static std::enable_if_t<!std::is_floating_point<T>::value && Enable, T>
346 update(T input, AH::Array<T, 2> &
w,
const AH::Array<T, 3> &
b,
347 const AH::Array<T, 2> &
a) {
348 input +=
a[0] *
w[0];
349 input +=
a[1] *
w[1];
350 T result =
b[0] * input;
351 result +=
b[1] *
w[0];
352 result +=
b[2] *
w[1];
369 AH::Array<T, 2>
w = {{}};
370 AH::Array<T, 3>
b = {{}};
371 AH::Array<T, 2>
a = {{}};
396 const AH::Array<T, 3> &
a)
397 :
b(
b),
a(-
a.template slice<1, 2>()),
a0(
a[0]) {}
403 const AH::Array<T, 3> &
a, T gain)
404 :
b(
b * gain),
a(-
a.template slice<1, 2>()),
a0(
a[0]) {}
410 template <
bool Enable = true>
411 static std::enable_if_t<std::is_floating_point<T>::value && Enable, T>
412 update(T input, AH::Array<T, 2> &
w,
const AH::Array<T, 3> &
b,
413 const AH::Array<T, 2> &
a, T
a0) {
414 input = std::fma(
a[0],
w[0], input);
415 input = std::fma(
a[1],
w[1], input);
417 T result =
b[0] * input;
418 result = std::fma(
b[1],
w[0], result);
419 result = std::fma(
b[2],
w[1], result);
425 template <
bool Enable = true>
426 static std::enable_if_t<!std::is_floating_point<T>::value && Enable, T>
427 update(T input, AH::Array<T, 2> &
w,
const AH::Array<T, 3> &
b,
428 const AH::Array<T, 2> &
a, T
a0) {
429 input +=
a[0] *
w[0];
430 input +=
a[1] *
w[1];
432 T result =
b[0] * input;
433 result +=
b[1] *
w[0];
434 result +=
b[2] *
w[1];
451 AH::Array<T, 2>
w = {{}};
452 AH::Array<T, 3>
b = {{}};
453 AH::Array<T, 2>
a = {{}};
463 typename std::conditional<std::is_floating_point<T>::value,
484template <
class T =
float>
506 const AH::Array<T, 3> &a_coefficients)
531 const AH::Array<T, 3> &a_coefficients, T gain)
typename std::conditional< std::is_floating_point< T >::value, NormalizingBiQuadFilterDF2< T >, NonNormalizingBiQuadFilterDF2< T > >::type BiQuadDF2Implementation
Select the NormalizingIIRFilter implementation if T is a floating point type, NonNormalizingIIRFilter...
typename std::conditional< std::is_floating_point< T >::value, NormalizingBiQuadFilterDF1< T >, NonNormalizingBiQuadFilterDF1< T > >::type BiQuadDF1Implementation
Select the NormalizingIIRFilter implementation if T is a floating point type, NonNormalizingIIRFilter...
Generic BiQuad (Bi-Quadratic) filter class, Direct Form 1 implementation.
BiQuadFilterDF1()=default
T operator()(T input)
Update the internal state with the new input and return the new output .
BiQuadFilterDF1(const AH::Array< T, 3 > &b_coefficients, const AH::Array< T, 3 > &a_coefficients, T gain)
Construct a new BiQuad (Bi-Quadratic) Filter object.
BiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients)
BiQuadFilterDF1(const AH::Array< T, 3 > &b_coefficients, const AH::Array< T, 3 > &a_coefficients)
Construct a new BiQuad (Bi-Quadratic) Filter object.
BiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients, T gain)
Generic BiQuad (Bi-Quadratic) filter class, Direct Form 2 implementation.
T operator()(T input)
Update the internal state with the new input and return the new output .
BiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients, T gain)
BiQuadFilterDF2()=default
BiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients)
BiQuadFilterDF2(const AH::Array< T, 3 > &b_coefficients, const AH::Array< T, 3 > &a_coefficients, T gain)
Construct a new BiQuad (Bi-Quadratic) Filter object.
BiQuadFilterDF2(const AH::Array< T, 3 > &b_coefficients, const AH::Array< T, 3 > &a_coefficients)
Construct a new BiQuad (Bi-Quadratic) Filter object.
BiQuad filter Direct Form 1 implementation that does not normalize the coefficients upon initializati...
NonNormalizingBiQuadFilterDF1()=default
static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a, T a0)
T operator()(T input)
Update the internal state with the new input and return the new output .
AH::Array< T, 2 > x
Previous inputs.
T a0
First denominator coefficient.
AH::Array< T, 2 > y
Previous outputs.
AH::Array< T, 2 > a
Denominator coefficients.
NonNormalizingBiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients, T gain)
AH::Array< T, 3 > b
Numerator coefficients.
static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a, T a0)
NonNormalizingBiQuadFilterDF1(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain)
NonNormalizingBiQuadFilterDF1(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a)
NonNormalizingBiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients)
BiQuad filter Direct Form 2 implementation that does not normalize the coefficients upon initializati...
T operator()(T input)
Update the internal state with the new input and return the new output .
static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &w, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a, T a0)
static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &w, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a, T a0)
NonNormalizingBiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients, T gain)
T a0
First denominator coefficient.
NonNormalizingBiQuadFilterDF2()=default
AH::Array< T, 2 > a
Denominator coefficients.
AH::Array< T, 3 > b
Numerator coefficients.
NonNormalizingBiQuadFilterDF2(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain)
AH::Array< T, 2 > w
Internal state.
NonNormalizingBiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients)
NonNormalizingBiQuadFilterDF2(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a)
BiQuad filter Direct Form 1 implementation that normalizes the coefficients upon initialization.
static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a)
NormalizingBiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients, T gain)
T operator()(T input)
Update the internal state with the new input and return the new output .
AH::Array< T, 2 > x
Previous inputs.
AH::Array< T, 2 > y
Previous outputs.
AH::Array< T, 2 > a
Denominator coefficients.
NormalizingBiQuadFilterDF1()=default
NormalizingBiQuadFilterDF1(const BiQuadCoefficients< T > &coefficients)
AH::Array< T, 3 > b
Numerator coefficients.
static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a)
NormalizingBiQuadFilterDF1(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a)
NormalizingBiQuadFilterDF1(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain)
BiQuad filter Direct Form 2 implementation that normalizes the coefficients upon initialization.
NormalizingBiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients, T gain)
NormalizingBiQuadFilterDF2(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain)
NormalizingBiQuadFilterDF2(const BiQuadCoefficients< T > &coefficients)
T operator()(T input)
Update the internal state with the new input and return the new output .
AH::Array< T, 2 > a
Denominator coefficients.
static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &w, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a)
AH::Array< T, 3 > b
Numerator coefficients.
NormalizingBiQuadFilterDF2(const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a)
AH::Array< T, 2 > w
Internal state.
static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > update(T input, AH::Array< T, 2 > &w, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a)
NormalizingBiQuadFilterDF2()=default
Class for transfer function coefficients.