不韋 呂
/
SDR_FM_Tx
AM中波放送用SDR.CICフィルタのみを使用.CQ出版社「トランジスタ技術」誌,2021年5月号に掲載
SDR_Library/Iir1st.hpp@0:7a653530c8ce, 2020-08-29 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sat Aug 29 11:26:29 2020 +0000
- Revision:
- 0:7a653530c8ce
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:7a653530c8ce | 1 | //----------------------------------------------------------------- |
MikamiUitOpen | 0:7a653530c8ce | 2 | // 一次の IIR フィルタ |
MikamiUitOpen | 0:7a653530c8ce | 3 | // y[n] = a1*y[n-1] + (1 - a1)*x[n] |
MikamiUitOpen | 0:7a653530c8ce | 4 | // |
MikamiUitOpen | 0:7a653530c8ce | 5 | // 2020/08/05, Copyright (c) 2020 MIKAMI, Naoki |
MikamiUitOpen | 0:7a653530c8ce | 6 | //----------------------------------------------------------------- |
MikamiUitOpen | 0:7a653530c8ce | 7 | |
MikamiUitOpen | 0:7a653530c8ce | 8 | #include "mbed.h" |
MikamiUitOpen | 0:7a653530c8ce | 9 | |
MikamiUitOpen | 0:7a653530c8ce | 10 | #ifndef IIR_1ST_HPP |
MikamiUitOpen | 0:7a653530c8ce | 11 | #define IIR_1ST_HPP |
MikamiUitOpen | 0:7a653530c8ce | 12 | namespace Mikami |
MikamiUitOpen | 0:7a653530c8ce | 13 | { |
MikamiUitOpen | 0:7a653530c8ce | 14 | class Iir1st |
MikamiUitOpen | 0:7a653530c8ce | 15 | { |
MikamiUitOpen | 0:7a653530c8ce | 16 | public: |
MikamiUitOpen | 0:7a653530c8ce | 17 | // コンストラクタ |
MikamiUitOpen | 0:7a653530c8ce | 18 | // a1 フィルタの係数 |
MikamiUitOpen | 0:7a653530c8ce | 19 | Iir1st(float a1) : A1_(a1), B0_(1.0f - a1), yn_(0) {} |
MikamiUitOpen | 0:7a653530c8ce | 20 | |
MikamiUitOpen | 0:7a653530c8ce | 21 | // フィルタの実行 |
MikamiUitOpen | 0:7a653530c8ce | 22 | float Execute(float xn) |
MikamiUitOpen | 0:7a653530c8ce | 23 | { |
MikamiUitOpen | 0:7a653530c8ce | 24 | yn_ = A1_*yn_ + B0_*xn; |
MikamiUitOpen | 0:7a653530c8ce | 25 | return yn_; |
MikamiUitOpen | 0:7a653530c8ce | 26 | } |
MikamiUitOpen | 0:7a653530c8ce | 27 | |
MikamiUitOpen | 0:7a653530c8ce | 28 | private: |
MikamiUitOpen | 0:7a653530c8ce | 29 | const float A1_; // フィルタ係数 |
MikamiUitOpen | 0:7a653530c8ce | 30 | const float B0_; // フィルタ係数 |
MikamiUitOpen | 0:7a653530c8ce | 31 | float yn_; // 出力 |
MikamiUitOpen | 0:7a653530c8ce | 32 | |
MikamiUitOpen | 0:7a653530c8ce | 33 | // コピー・コンストラクタ,代入演算子の禁止のため |
MikamiUitOpen | 0:7a653530c8ce | 34 | Iir1st(const Iir1st&); |
MikamiUitOpen | 0:7a653530c8ce | 35 | Iir1st& operator=(const Iir1st&); |
MikamiUitOpen | 0:7a653530c8ce | 36 | }; |
MikamiUitOpen | 0:7a653530c8ce | 37 | } |
MikamiUitOpen | 0:7a653530c8ce | 38 | #endif // IIR_1ST_HPP |