![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ファンクション・ジェネレータ
Dependencies: mbed SerialTxRxIntr MyTicker7 Array_Matrix
IIR_Cascade/Biquad.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 フィルタの構成要素として使う 2 次の IIR フィルタ |
MikamiUitOpen | 0:17c762b41fc7 | 3 | // b0 は 1 と仮定している |
MikamiUitOpen | 0:17c762b41fc7 | 4 | // |
MikamiUitOpen | 0:17c762b41fc7 | 5 | // 2020/02/12, Copyright (c) 2020 MIKAMI, Naoki |
MikamiUitOpen | 0:17c762b41fc7 | 6 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:17c762b41fc7 | 7 | |
MikamiUitOpen | 0:17c762b41fc7 | 8 | #include "Biquad.hpp" |
MikamiUitOpen | 0:17c762b41fc7 | 9 | |
MikamiUitOpen | 0:17c762b41fc7 | 10 | namespace Mikami |
MikamiUitOpen | 0:17c762b41fc7 | 11 | { |
MikamiUitOpen | 0:17c762b41fc7 | 12 | // デフォルト・コンストラクタ |
MikamiUitOpen | 0:17c762b41fc7 | 13 | // 係数は構造体 Ceofs で与える |
MikamiUitOpen | 0:17c762b41fc7 | 14 | Biquad::Biquad(const Coefs ck) |
MikamiUitOpen | 0:17c762b41fc7 | 15 | : a1_(ck.a1), a2_(ck.a2), b1_(ck.b1), b2_(ck.b2) { Clear(); } |
MikamiUitOpen | 0:17c762b41fc7 | 16 | |
MikamiUitOpen | 0:17c762b41fc7 | 17 | // 係数を個別に与えるコンストラクタ |
MikamiUitOpen | 0:17c762b41fc7 | 18 | Biquad::Biquad(float a1, float a2, float b1, float b2) |
MikamiUitOpen | 0:17c762b41fc7 | 19 | : a1_(a1), a2_(a2), b1_(b1), b2_(b2) { Clear(); } |
MikamiUitOpen | 0:17c762b41fc7 | 20 | |
MikamiUitOpen | 0:17c762b41fc7 | 21 | // 2 次のフィルタを実行する |
MikamiUitOpen | 0:17c762b41fc7 | 22 | float Biquad::Execute(float xn) |
MikamiUitOpen | 0:17c762b41fc7 | 23 | { |
MikamiUitOpen | 0:17c762b41fc7 | 24 | float un = xn + a1_*un1_ + a2_*un2_; |
MikamiUitOpen | 0:17c762b41fc7 | 25 | float yn = un + b1_*un1_ + b2_*un2_; |
MikamiUitOpen | 0:17c762b41fc7 | 26 | |
MikamiUitOpen | 0:17c762b41fc7 | 27 | un2_ = un1_; |
MikamiUitOpen | 0:17c762b41fc7 | 28 | un1_ = un; |
MikamiUitOpen | 0:17c762b41fc7 | 29 | |
MikamiUitOpen | 0:17c762b41fc7 | 30 | return yn; |
MikamiUitOpen | 0:17c762b41fc7 | 31 | } |
MikamiUitOpen | 0:17c762b41fc7 | 32 | |
MikamiUitOpen | 0:17c762b41fc7 | 33 | // 係数を設定する |
MikamiUitOpen | 0:17c762b41fc7 | 34 | void Biquad::SetCoefs(const Coefs ck) |
MikamiUitOpen | 0:17c762b41fc7 | 35 | { |
MikamiUitOpen | 0:17c762b41fc7 | 36 | a1_ = ck.a1; |
MikamiUitOpen | 0:17c762b41fc7 | 37 | a2_ = ck.a2; |
MikamiUitOpen | 0:17c762b41fc7 | 38 | b1_ = ck.b1; |
MikamiUitOpen | 0:17c762b41fc7 | 39 | b2_ = ck.b2; |
MikamiUitOpen | 0:17c762b41fc7 | 40 | } |
MikamiUitOpen | 0:17c762b41fc7 | 41 | } |