![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ファンクション・ジェネレータ
Dependencies: mbed SerialTxRxIntr MyTicker7 Array_Matrix
IIR_Cascade/IIR_Cascade.cpp@1:ea5aa7f3d68c, 2020-12-23 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Dec 23 01:07:09 2020 +0000
- Revision:
- 1:ea5aa7f3d68c
- Parent:
- 0:17c762b41fc7
2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:17c762b41fc7 | 1 | //--------------------------------------------------- |
MikamiUitOpen | 0:17c762b41fc7 | 2 | // 縦続形 IIR フィルタ |
MikamiUitOpen | 0:17c762b41fc7 | 3 | // |
MikamiUitOpen | 0:17c762b41fc7 | 4 | // 2020/05/30, Copyright (c) 2020 MIKAMI, Naoki |
MikamiUitOpen | 0:17c762b41fc7 | 5 | //--------------------------------------------------- |
MikamiUitOpen | 0:17c762b41fc7 | 6 | |
MikamiUitOpen | 0:17c762b41fc7 | 7 | #include "IIR_Cascade.hpp" |
MikamiUitOpen | 0:17c762b41fc7 | 8 | |
MikamiUitOpen | 0:17c762b41fc7 | 9 | namespace Mikami |
MikamiUitOpen | 0:17c762b41fc7 | 10 | { |
MikamiUitOpen | 0:17c762b41fc7 | 11 | // コンストラクタ |
MikamiUitOpen | 0:17c762b41fc7 | 12 | IirCascade::IirCascade(int order, const Biquad::Coefs ck[], float g0) |
MikamiUitOpen | 0:17c762b41fc7 | 13 | { |
MikamiUitOpen | 0:17c762b41fc7 | 14 | SetCoefs(order, ck, g0); |
MikamiUitOpen | 0:17c762b41fc7 | 15 | Clear(); |
MikamiUitOpen | 0:17c762b41fc7 | 16 | } |
MikamiUitOpen | 0:17c762b41fc7 | 17 | |
MikamiUitOpen | 0:17c762b41fc7 | 18 | // フィルタ処理を実行する |
MikamiUitOpen | 0:17c762b41fc7 | 19 | float IirCascade::Execute(float xn) |
MikamiUitOpen | 0:17c762b41fc7 | 20 | { |
MikamiUitOpen | 0:17c762b41fc7 | 21 | float yn = g0_*xn; |
MikamiUitOpen | 0:17c762b41fc7 | 22 | for (int k=0; k<hOrder_; k++) yn = bq_[k].Execute(yn); |
MikamiUitOpen | 0:17c762b41fc7 | 23 | return yn; |
MikamiUitOpen | 0:17c762b41fc7 | 24 | } |
MikamiUitOpen | 0:17c762b41fc7 | 25 | |
MikamiUitOpen | 0:17c762b41fc7 | 26 | // 係数の設定 |
MikamiUitOpen | 0:17c762b41fc7 | 27 | void IirCascade::SetCoefs(int order, const Biquad::Coefs ck[], float g0) |
MikamiUitOpen | 0:17c762b41fc7 | 28 | { |
MikamiUitOpen | 0:17c762b41fc7 | 29 | printf("SetCoefs called!\r\n"); |
MikamiUitOpen | 0:17c762b41fc7 | 30 | if (hOrder_ != ((order+1)>>1)) |
MikamiUitOpen | 0:17c762b41fc7 | 31 | { |
MikamiUitOpen | 0:17c762b41fc7 | 32 | hOrder_ = (order+1)>>1; |
MikamiUitOpen | 0:17c762b41fc7 | 33 | bq_.SetSize(hOrder_); |
MikamiUitOpen | 0:17c762b41fc7 | 34 | Clear(); |
MikamiUitOpen | 0:17c762b41fc7 | 35 | printf("Order changed!\r\n"); |
MikamiUitOpen | 0:17c762b41fc7 | 36 | } |
MikamiUitOpen | 0:17c762b41fc7 | 37 | g0_ = g0; |
MikamiUitOpen | 0:17c762b41fc7 | 38 | for (int k=0; k<hOrder_; k++) bq_[k].SetCoefs(ck[k]); |
MikamiUitOpen | 0:17c762b41fc7 | 39 | } |
MikamiUitOpen | 0:17c762b41fc7 | 40 | } |