![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Chapter003_TRobot
Dependencies: F746_GUI Array_Matrix TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG SDFileSystem_Warning_Fixed FrequencyResponseDrawer F746_SAI_IO
MyClasses_Functions/IIR_CascadeFrqResp.hpp@0:04b43b777fae, 2016-04-19 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Apr 19 09:46:11 2016 +0000
- Revision:
- 0:04b43b777fae
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:04b43b777fae | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:04b43b777fae | 2 | // Frequency response for IIR filter of cascade form |
MikamiUitOpen | 0:04b43b777fae | 3 | // |
MikamiUitOpen | 0:04b43b777fae | 4 | // 2016/04/16, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:04b43b777fae | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:04b43b777fae | 6 | |
MikamiUitOpen | 0:04b43b777fae | 7 | #ifndef IIR_CASCADE_FREQUENCY_RESPONSE_HPP |
MikamiUitOpen | 0:04b43b777fae | 8 | #define IIR_CASCADE_FREQUENCY_RESPONSE_HPP |
MikamiUitOpen | 0:04b43b777fae | 9 | |
MikamiUitOpen | 0:04b43b777fae | 10 | #include "FrequancyResponseBase.hpp" |
MikamiUitOpen | 0:04b43b777fae | 11 | #include "Biquad.hpp" |
MikamiUitOpen | 0:04b43b777fae | 12 | |
MikamiUitOpen | 0:04b43b777fae | 13 | namespace Mikami |
MikamiUitOpen | 0:04b43b777fae | 14 | { |
MikamiUitOpen | 0:04b43b777fae | 15 | class IIR_CascadeFrqResp : public FrequencyResponse |
MikamiUitOpen | 0:04b43b777fae | 16 | { |
MikamiUitOpen | 0:04b43b777fae | 17 | public: |
MikamiUitOpen | 0:04b43b777fae | 18 | IIR_CascadeFrqResp() {} |
MikamiUitOpen | 0:04b43b777fae | 19 | |
MikamiUitOpen | 0:04b43b777fae | 20 | // 次数とフィルタの係数設定 |
MikamiUitOpen | 0:04b43b777fae | 21 | void SetParams(int order, float g0, Biquad::Coefs ck[]) |
MikamiUitOpen | 0:04b43b777fae | 22 | { |
MikamiUitOpen | 0:04b43b777fae | 23 | order_ = order; |
MikamiUitOpen | 0:04b43b777fae | 24 | g0_ = g0; |
MikamiUitOpen | 0:04b43b777fae | 25 | ck_ = ck; |
MikamiUitOpen | 0:04b43b777fae | 26 | } |
MikamiUitOpen | 0:04b43b777fae | 27 | |
MikamiUitOpen | 0:04b43b777fae | 28 | // 周波数応答の絶対値を返す関数, 引数: z^(-1) |
MikamiUitOpen | 0:04b43b777fae | 29 | virtual float AbsH_z(Complex u) |
MikamiUitOpen | 0:04b43b777fae | 30 | { |
MikamiUitOpen | 0:04b43b777fae | 31 | Complex h = g0_; |
MikamiUitOpen | 0:04b43b777fae | 32 | for (int k=0; k<order_/2; k++) |
MikamiUitOpen | 0:04b43b777fae | 33 | h = h*(1.0f + (ck_[k].b1 + ck_[k].b2*u)*u) |
MikamiUitOpen | 0:04b43b777fae | 34 | /((1.0f - (ck_[k].a1 + ck_[k].a2*u)*u)); |
MikamiUitOpen | 0:04b43b777fae | 35 | return abs(h); |
MikamiUitOpen | 0:04b43b777fae | 36 | } |
MikamiUitOpen | 0:04b43b777fae | 37 | |
MikamiUitOpen | 0:04b43b777fae | 38 | private: |
MikamiUitOpen | 0:04b43b777fae | 39 | int order_; |
MikamiUitOpen | 0:04b43b777fae | 40 | float g0_; |
MikamiUitOpen | 0:04b43b777fae | 41 | Biquad::Coefs *ck_; |
MikamiUitOpen | 0:04b43b777fae | 42 | |
MikamiUitOpen | 0:04b43b777fae | 43 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:04b43b777fae | 44 | IIR_CascadeFrqResp(const IIR_CascadeFrqResp&); |
MikamiUitOpen | 0:04b43b777fae | 45 | IIR_CascadeFrqResp& operator=(const IIR_CascadeFrqResp&); |
MikamiUitOpen | 0:04b43b777fae | 46 | }; |
MikamiUitOpen | 0:04b43b777fae | 47 | } |
MikamiUitOpen | 0:04b43b777fae | 48 | #endif // IIR_CASCADE_FREQUENCY_RESPONSE_HPP |