diff options
Diffstat (limited to 'src/biquad.h')
-rw-r--r-- | src/biquad.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/biquad.h b/src/biquad.h new file mode 100644 index 0000000..d897062 --- /dev/null +++ b/src/biquad.h @@ -0,0 +1,42 @@ +#ifndef BIQUAD__H +#define BIQUAD__H +#include <complex> +#include <vector> + +// typical usage: +// biquad butterworth({1., 2., 1.}, +// {1., -1.99911142347079540116, 0.99911181807963833634}); + +typedef std::complex<double> C; + +class biquad{ +public: +// d0 must always be 1 + std::vector<double> c, d; + std::vector<C> zeros, poles; + double ws1, ws2; // remembered weighted sums + + C static constexpr C0 = C(0, 0); + C static constexpr C1 = C(1, 0); +// gory-detail constructor +biquad(std::vector<double> const _c, std::vector<double> const _d, + std::vector<C> _zeros, std::vector<C> _poles); + +// constructor in terms of coefficients: +biquad(std::vector<double> const _c, std::vector<double> const _d); + +// constructor in terms of zero and pole position, +// assuming conjugate pairs: + biquad(C const zero, C const pole); + +// time-domain evaluation: + double step(double const Vin); + +// z-plane transfer function + C xfunc(const C z) const; + + void normalize(C const z = 1); + void please_normalize(C const z = 1); +}; + +#endif |