2016-09-10 13:03:27 -07:00
|
|
|
/*
|
|
|
|
* @file biquad.h
|
|
|
|
*
|
|
|
|
* @date Sep 10, 2016
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2016-09-10 13:03:27 -07:00
|
|
|
*/
|
|
|
|
|
2020-04-01 18:32:21 -07:00
|
|
|
#pragma once
|
2016-09-10 13:03:27 -07:00
|
|
|
|
|
|
|
class Biquad {
|
|
|
|
public:
|
2020-08-21 16:47:12 -07:00
|
|
|
Biquad();
|
|
|
|
|
2020-08-28 18:13:50 -07:00
|
|
|
float filter(float input);
|
|
|
|
void reset();
|
|
|
|
void cookSteadyState(float steadyStateInput);
|
2020-08-21 16:47:12 -07:00
|
|
|
|
|
|
|
void configureBandpass(float samplingFrequency, float centerFrequency, float Q);
|
|
|
|
|
2021-01-08 16:48:56 -08:00
|
|
|
// Default Q = 0.54, which is the maximum quality factor without time domain overshoot
|
|
|
|
// note that it is less than the maximally flat (frequency domain) Q=0.707, which gives some overshoot
|
|
|
|
void configureLowpass(float samplingFrequency, float cutoffFrequency, float Q = 0.54f);
|
2016-09-10 13:03:27 -07:00
|
|
|
|
2020-08-21 16:47:12 -07:00
|
|
|
private:
|
2020-08-28 18:13:50 -07:00
|
|
|
float a0, a1, a2, b1, b2;
|
|
|
|
float z1, z2;
|
2016-09-10 13:03:27 -07:00
|
|
|
};
|