![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ファンクション・ジェネレータ
Dependencies: mbed SerialTxRxIntr MyTicker7 Array_Matrix
IIR_Cascade/Biquad.hpp@0:17c762b41fc7, 2020-10-17 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sat Oct 17 10:05:58 2020 +0000
- Revision:
- 0:17c762b41fc7
1
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 | #ifndef IIR_BIQUAD_HPP |
MikamiUitOpen | 0:17c762b41fc7 | 9 | #define IIR_BIQUAD_HPP |
MikamiUitOpen | 0:17c762b41fc7 | 10 | |
MikamiUitOpen | 0:17c762b41fc7 | 11 | #include "mbed.h" |
MikamiUitOpen | 0:17c762b41fc7 | 12 | |
MikamiUitOpen | 0:17c762b41fc7 | 13 | namespace Mikami |
MikamiUitOpen | 0:17c762b41fc7 | 14 | { |
MikamiUitOpen | 0:17c762b41fc7 | 15 | class Biquad |
MikamiUitOpen | 0:17c762b41fc7 | 16 | { |
MikamiUitOpen | 0:17c762b41fc7 | 17 | public: |
MikamiUitOpen | 0:17c762b41fc7 | 18 | // フィルタの係数をまとめて扱うための構造体 |
MikamiUitOpen | 0:17c762b41fc7 | 19 | struct Coefs { float a1, a2, b1, b2; }; |
MikamiUitOpen | 0:17c762b41fc7 | 20 | |
MikamiUitOpen | 0:17c762b41fc7 | 21 | // デフォルト・コンストラクタ |
MikamiUitOpen | 0:17c762b41fc7 | 22 | // 係数は構造体 Ceofs で与える |
MikamiUitOpen | 0:17c762b41fc7 | 23 | Biquad(const Coefs ck = (Coefs){0, 0, 0, 0}); |
MikamiUitOpen | 0:17c762b41fc7 | 24 | |
MikamiUitOpen | 0:17c762b41fc7 | 25 | // 係数を個別に与えるコンストラクタ |
MikamiUitOpen | 0:17c762b41fc7 | 26 | Biquad(float a1, float a2, float b1, float b2); |
MikamiUitOpen | 0:17c762b41fc7 | 27 | |
MikamiUitOpen | 0:17c762b41fc7 | 28 | // 2 次のフィルタを実行する |
MikamiUitOpen | 0:17c762b41fc7 | 29 | float Execute(float xn); |
MikamiUitOpen | 0:17c762b41fc7 | 30 | |
MikamiUitOpen | 0:17c762b41fc7 | 31 | // 係数を設定する |
MikamiUitOpen | 0:17c762b41fc7 | 32 | void SetCoefs(const Coefs ck); |
MikamiUitOpen | 0:17c762b41fc7 | 33 | |
MikamiUitOpen | 0:17c762b41fc7 | 34 | // 内部変数(遅延器)のクリア |
MikamiUitOpen | 0:17c762b41fc7 | 35 | void Clear() { un1_ = un2_ = 0; } |
MikamiUitOpen | 0:17c762b41fc7 | 36 | |
MikamiUitOpen | 0:17c762b41fc7 | 37 | private: |
MikamiUitOpen | 0:17c762b41fc7 | 38 | float a1_, a2_, b1_, b2_; |
MikamiUitOpen | 0:17c762b41fc7 | 39 | float un1_, un2_; |
MikamiUitOpen | 0:17c762b41fc7 | 40 | |
MikamiUitOpen | 0:17c762b41fc7 | 41 | // コピー・コンストラクタ禁止のため |
MikamiUitOpen | 0:17c762b41fc7 | 42 | Biquad(const Biquad&); |
MikamiUitOpen | 0:17c762b41fc7 | 43 | }; |
MikamiUitOpen | 0:17c762b41fc7 | 44 | } |
MikamiUitOpen | 0:17c762b41fc7 | 45 | #endif // IIR_BIQUAD_HPP |