Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
filter_state.hpp
Go to the documentation of this file.
1#pragma once
2
3// Sanitized recursive filter state shared by the FDN's coefficient-driven
4// biquads. Recursive stages recover locally from non-finite input or state and
5// snap their state words out of the denormal range as the tail decays.
6
10
11namespace pulp::signal::fdn {
12
14 public:
15 void reset() {
16 s1_ = 0.0;
17 s2_ = 0.0;
18 }
19
20 double process(const BiquadCoefficientsT<double>& coefficients, double input) {
21 const double in = finite_or_zero(input);
22 const double output = finite_or_zero(coefficients.b0 * in + s1_);
23 s1_ = finite_or_zero(snap_to_zero(coefficients.b1 * in - coefficients.a1 * output + s2_));
24 s2_ = finite_or_zero(snap_to_zero(coefficients.b2 * in - coefficients.a2 * output));
25 return output;
26 }
27
28 private:
29 double s1_ = 0.0;
30 double s2_ = 0.0;
31};
32
33} // namespace pulp::signal::fdn
Definition filter_state.hpp:13
double process(const BiquadCoefficientsT< double > &coefficients, double input)
Definition filter_state.hpp:20
void reset()
Definition filter_state.hpp:15
Definition config.hpp:15
T finite_or_zero(T value)
Definition sanitize.hpp:12
T snap_to_zero(T x)
Returns 0 if |x| < snap_threshold, else x.
Definition denormal.hpp:45
Definition biquad.hpp:24
SampleType b0
Definition biquad.hpp:25
SampleType a2
Definition biquad.hpp:26
SampleType a1
Definition biquad.hpp:26
SampleType b2
Definition biquad.hpp:25
SampleType b1
Definition biquad.hpp:25