From 9852b855db2a65ea6eb5e877411634820214ddf0 Mon Sep 17 00:00:00 2001 From: John Denker Date: Sat, 16 Mar 2024 11:21:23 -0700 Subject: initial setup --- src/biquad.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/biquad.h (limited to 'src/biquad.h') 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 +#include + +// typical usage: +// biquad butterworth({1., 2., 1.}, +// {1., -1.99911142347079540116, 0.99911181807963833634}); + +typedef std::complex C; + +class biquad{ +public: +// d0 must always be 1 + std::vector c, d; + std::vector 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 const _c, std::vector const _d, + std::vector _zeros, std::vector _poles); + +// constructor in terms of coefficients: +biquad(std::vector const _c, std::vector 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 -- cgit v1.2.3