Mercurial > hg > beaglert
view projects/d-box/Biquad.h @ 23:182ae9367104 matrix_gpio
- persistency: the last frame of each digital and analogOut buffers is used to initialize all the frames in the next buffer. This means that once a value is set, the pin will hold the value until you change it
- AnalogXyz macros have been renamed to analogXyz
- the short option -P has been removed. The long option --pru-file has to be used instead
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 05 May 2015 17:28:00 +0100 |
parents | 8a575ba3ab52 |
children |
line wrap: on
line source
// // Biquad.h // // Created by Nigel Redmon on 11/24/12 // EarLevel Engineering: earlevel.com // Copyright 2012 Nigel Redmon // // For a complete explanation of the Biquad code: // http://www.earlevel.com/main/2012/11/25/biquad-c-source-code/ // // License: // // This source code is provided as is, without warranty. // You may copy and distribute verbatim copies of this document. // You may modify and use this source code to create binary code // for your own purposes, free or commercial. // #ifndef Biquad_h #define Biquad_h enum { bq_type_lowpass = 0, bq_type_highpass, bq_type_bandpass, bq_type_notch, bq_type_peak, bq_type_lowshelf, bq_type_highshelf }; class Biquad { public: Biquad(); Biquad(int type, double Fc, double Q, double peakGainDB); ~Biquad(); void setType(int type); void setQ(double Q); void setFc(double Fc); void setPeakGain(double peakGainDB); void setBiquad(int type, double Fc, double Q, double peakGain); float process(float in); double getQ(); double getFc(); double getPeakGain(); double getStartingQ(); double getStartingFc(); double getStartingPeakGain(); protected: void calcBiquad(void); int type; double a0, a1, a2, b1, b2; double Fc, Q, peakGain; double startFc, startQ, startPeakGain; double z1, z2; }; inline double Biquad::getQ() { return Q; } inline double Biquad::getFc() { return Fc; } inline double Biquad::getPeakGain() { return peakGain; } inline double Biquad::getStartingQ() { return startQ; } inline double Biquad::getStartingFc() { return startFc; } inline double Biquad::getStartingPeakGain() { return startPeakGain; } inline float Biquad::process(float in) { double out = in * a0 + z1; z1 = in * a1 + z2 - b1 * out; z2 = in * a2 - b2 * out; return out; } #endif // Biquad_h