AM中波放送用SDR.CICフィルタと通常のFIRフィルタを組み合わせて使用.CQ出版社「トランジスタ技術」誌に掲載予定

Dependencies:   mbed

Committer:
MikamiUitOpen
Date:
Sat Aug 29 11:25:01 2020 +0000
Revision:
0:9c28f5905a1a
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:9c28f5905a1a 1 //-----------------------------------------------------------------
MikamiUitOpen 0:9c28f5905a1a 2 // 一次の IIR フィルタ
MikamiUitOpen 0:9c28f5905a1a 3 // y[n] = a1*y[n-1] + (1 - a1)*x[n]
MikamiUitOpen 0:9c28f5905a1a 4 //
MikamiUitOpen 0:9c28f5905a1a 5 // 2020/08/05, Copyright (c) 2020 MIKAMI, Naoki
MikamiUitOpen 0:9c28f5905a1a 6 //-----------------------------------------------------------------
MikamiUitOpen 0:9c28f5905a1a 7
MikamiUitOpen 0:9c28f5905a1a 8 #include "mbed.h"
MikamiUitOpen 0:9c28f5905a1a 9
MikamiUitOpen 0:9c28f5905a1a 10 #ifndef IIR_1ST_HPP
MikamiUitOpen 0:9c28f5905a1a 11 #define IIR_1ST_HPP
MikamiUitOpen 0:9c28f5905a1a 12 namespace Mikami
MikamiUitOpen 0:9c28f5905a1a 13 {
MikamiUitOpen 0:9c28f5905a1a 14 class Iir1st
MikamiUitOpen 0:9c28f5905a1a 15 {
MikamiUitOpen 0:9c28f5905a1a 16 public:
MikamiUitOpen 0:9c28f5905a1a 17 // コンストラクタ
MikamiUitOpen 0:9c28f5905a1a 18 // a1 フィルタの係数
MikamiUitOpen 0:9c28f5905a1a 19 Iir1st(float a1) : A1_(a1), B0_(1.0f - a1), yn_(0) {}
MikamiUitOpen 0:9c28f5905a1a 20
MikamiUitOpen 0:9c28f5905a1a 21 // フィルタの実行
MikamiUitOpen 0:9c28f5905a1a 22 float Execute(float xn)
MikamiUitOpen 0:9c28f5905a1a 23 {
MikamiUitOpen 0:9c28f5905a1a 24 yn_ = A1_*yn_ + B0_*xn;
MikamiUitOpen 0:9c28f5905a1a 25 return yn_;
MikamiUitOpen 0:9c28f5905a1a 26 }
MikamiUitOpen 0:9c28f5905a1a 27
MikamiUitOpen 0:9c28f5905a1a 28 private:
MikamiUitOpen 0:9c28f5905a1a 29 const float A1_; // フィルタ係数
MikamiUitOpen 0:9c28f5905a1a 30 const float B0_; // フィルタ係数
MikamiUitOpen 0:9c28f5905a1a 31 float yn_; // 出力
MikamiUitOpen 0:9c28f5905a1a 32
MikamiUitOpen 0:9c28f5905a1a 33 // コピー・コンストラクタ,代入演算子の禁止のため
MikamiUitOpen 0:9c28f5905a1a 34 Iir1st(const Iir1st&);
MikamiUitOpen 0:9c28f5905a1a 35 Iir1st& operator=(const Iir1st&);
MikamiUitOpen 0:9c28f5905a1a 36 };
MikamiUitOpen 0:9c28f5905a1a 37 }
MikamiUitOpen 0:9c28f5905a1a 38 #endif // IIR_1ST_HPP