![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Frequency shifter using Weaver modulator for ST Nucleo F401RE.
Dependencies: UITDSP_ADDA mbed
Biquad.hpp@1:013f4e5762b1, 2015-07-25 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sat Jul 25 09:03:13 2015 +0000
- Revision:
- 1:013f4e5762b1
- Parent:
- 0:c17cb8371b55
2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:c17cb8371b55 | 1 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:c17cb8371b55 | 2 | // Biquad filter for IIR filter of cascade structure |
MikamiUitOpen | 0:c17cb8371b55 | 3 | // 2014/10/21, Copyright (c) 2014 MIKAMI, Naoki |
MikamiUitOpen | 0:c17cb8371b55 | 4 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:c17cb8371b55 | 5 | |
MikamiUitOpen | 0:c17cb8371b55 | 6 | #ifndef IIR_BIQUAD_HPP |
MikamiUitOpen | 0:c17cb8371b55 | 7 | #define IIR_BIQUAD_HPP |
MikamiUitOpen | 0:c17cb8371b55 | 8 | |
MikamiUitOpen | 0:c17cb8371b55 | 9 | #include "mbed.h" |
MikamiUitOpen | 0:c17cb8371b55 | 10 | |
MikamiUitOpen | 0:c17cb8371b55 | 11 | // 2nd order IIR filter |
MikamiUitOpen | 0:c17cb8371b55 | 12 | namespace Mikami |
MikamiUitOpen | 0:c17cb8371b55 | 13 | { |
MikamiUitOpen | 0:c17cb8371b55 | 14 | class Biquad |
MikamiUitOpen | 0:c17cb8371b55 | 15 | { |
MikamiUitOpen | 0:c17cb8371b55 | 16 | public: |
MikamiUitOpen | 0:c17cb8371b55 | 17 | struct Coefs { float a1, a2, b1, b2; }; |
MikamiUitOpen | 0:c17cb8371b55 | 18 | |
MikamiUitOpen | 0:c17cb8371b55 | 19 | Biquad() {} // Default constructore |
MikamiUitOpen | 0:c17cb8371b55 | 20 | |
MikamiUitOpen | 0:c17cb8371b55 | 21 | Biquad(const Coefs ck) |
MikamiUitOpen | 0:c17cb8371b55 | 22 | : a1_(ck.a1), a2_(ck.a2), b1_(ck.b1), b2_(ck.b2) |
MikamiUitOpen | 0:c17cb8371b55 | 23 | { Clear(); } |
MikamiUitOpen | 0:c17cb8371b55 | 24 | |
MikamiUitOpen | 0:c17cb8371b55 | 25 | float Execute(float xn) |
MikamiUitOpen | 0:c17cb8371b55 | 26 | { |
MikamiUitOpen | 0:c17cb8371b55 | 27 | float un = xn + a1_*un1_ + a2_*un2_; |
MikamiUitOpen | 0:c17cb8371b55 | 28 | float yn = un + b1_*un1_ + b2_*un2_; |
MikamiUitOpen | 0:c17cb8371b55 | 29 | |
MikamiUitOpen | 0:c17cb8371b55 | 30 | un2_ = un1_; |
MikamiUitOpen | 0:c17cb8371b55 | 31 | un1_ = un; |
MikamiUitOpen | 0:c17cb8371b55 | 32 | |
MikamiUitOpen | 0:c17cb8371b55 | 33 | return yn; |
MikamiUitOpen | 0:c17cb8371b55 | 34 | } |
MikamiUitOpen | 0:c17cb8371b55 | 35 | |
MikamiUitOpen | 0:c17cb8371b55 | 36 | void Clear() { un1_ = un2_ = 0; } |
MikamiUitOpen | 0:c17cb8371b55 | 37 | |
MikamiUitOpen | 0:c17cb8371b55 | 38 | private: |
MikamiUitOpen | 0:c17cb8371b55 | 39 | float a1_, a2_, b1_, b2_; |
MikamiUitOpen | 0:c17cb8371b55 | 40 | float un1_, un2_; |
MikamiUitOpen | 0:c17cb8371b55 | 41 | |
MikamiUitOpen | 0:c17cb8371b55 | 42 | Biquad(const Biquad&); |
MikamiUitOpen | 0:c17cb8371b55 | 43 | }; |
MikamiUitOpen | 0:c17cb8371b55 | 44 | } |
MikamiUitOpen | 0:c17cb8371b55 | 45 | #endif // IIR_BIQUAD_HPP |
MikamiUitOpen | 0:c17cb8371b55 | 46 | |
MikamiUitOpen | 0:c17cb8371b55 | 47 | |
MikamiUitOpen | 0:c17cb8371b55 | 48 |