PosturePerfection
iir.h
Go to the documentation of this file.
1 
21 #ifndef SRC_IIR_H_
22 #define SRC_IIR_H_
23 
24 #include <stdlib.h>
25 
26 #include <vector>
27 
32 namespace IIR {
33 
38 struct Nodes {
39  float b0;
40  float b1;
41  float b2;
42  float a0;
43  float a1;
44  float a2;
45  float tap1;
46  float tap2;
47 };
48 
61  std::vector<std::vector<float>> coefficients;
62 };
63 
69  private:
70  Nodes nodes;
71 
72  public:
79  explicit IIR2ndOrderFilter(std::vector<float> coefficients);
80 
89  float run(float x);
90 };
91 
102 class IIRFilter {
103  private:
108  std::vector<IIR2ndOrderFilter> filters;
109 
110  public:
119  explicit IIRFilter(SmoothingSettings smoothing_settings);
120 
126  void set(float x);
127 
136  float run(float x);
137 };
138 
139 } // namespace IIR
140 #endif // SRC_IIR_H_
Second-order IIR filter stage, for use with the IIRFilter
Definition: iir.h:68
float run(float x)
Apply the filter to the next data sample, x
Definition: iir.cpp:41
IIR2ndOrderFilter(std::vector< float > coefficients)
Construct a new IIR2ndOrderFilter object.
Definition: iir.cpp:28
An IIR filter that can be initialised with SOS coefficients.
Definition: iir.h:102
float run(float x)
Apply the filter to the next data sample, x
Definition: iir.cpp:84
void set(float x)
Set all data in the filter to the given value.
Definition: iir.cpp:58
IIRFilter(SmoothingSettings smoothing_settings)
Construct a new IIRFilter object.
Definition: iir.cpp:52
Perform IIR filtering to smoothen the output results.
Definition: iir.cpp:27
Taps inside the second-order IIR filter.
Definition: iir.h:38
float tap2
Definition: iir.h:46
float a1
Definition: iir.h:43
float b2
Definition: iir.h:41
float b0
Definition: iir.h:39
float tap1
Definition: iir.h:45
float a2
Definition: iir.h:44
float a0
Definition: iir.h:42
float b1
Definition: iir.h:40
Settings for an IIR filter. Wraps the second-order section coefficients for an IIR filter.
Definition: iir.h:54
std::vector< std::vector< float > > coefficients
The sos_coefficients are a 2D vector, where the rows correspond to each of the second order stages,...
Definition: iir.h:61