Biquad Filter#
The BiquadFilter class provides an implementation of a Digital Biequad Filter with implementations for both the Direct Form 1 and Direct Form 2.
API Reference#
Header File#
Classes#
-
class BiquadFilterDf1#
Digital Biquadratic Filter (Direct Form 1).
Implements the following difference equation:
\[y[n] = \frac{b_0 * x[n] + b_1 * x[n-1] + b_2 * x[n-2] - a_1 * y[n-1] - a_2 * y[n-2]}{a_0} \]Note
This filter is normalized (meaning the coefficients it uses will have already been divided by a[0])
Public Functions
-
inline float update(float input)#
Filter the signal sampled by input, updating internal state, and returning the filtered output.
- Parameters:
input – New sample of the input data.
- Returns:
Filtered output based on input and history.
-
inline float update(float input)#
-
class BiquadFilterDf2#
Digital Biquadratic Filter (Direct Form 2). Direct form 2 only needs N delay units (N is the order), which is potentially half as much as Direct Form 1, however with Direct Form 2 there is a higher risk of arithmetic overflow. This implementation uses the esp-dsp implementation of optimized biquad direct form 2 filter function.
Implements the following difference equation:
\[y[n] = \frac{b_0 * x[n] + b_1 * x[n-1] + b_2 * x[n-2] - a_1 * y[n-1] - a_2 * y[n-2]}{a_0} \]Note
This filter is normalized (meaning the coefficients it uses will have already been divided by a[0])
Public Functions
-
inline void update(const float *input, float *output, size_t length)#
Filter the signal sampled by input, updating internal state, and returning the filtered output.
- Parameters:
input – Pointer to (floating point) array of new samples of the input data
output – Pointer to (floating point) array which will be filled with the filtered input.
length – Number of samples, should be >= length of input & output memory.
-
inline float update(const float input)#
Filter the signal sampled by input, updating internal state, and returning the filtered output.
- Parameters:
input – New sample of the input data.
- Returns:
Filtered output based on input and history.
-
inline void update(const float *input, float *output, size_t length)#