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

Dependencies:   mbed

Committer:
tza
Date:
Sat Jul 31 09:11:29 2021 +0000
Revision:
1:ca43ee5ea802
Parent:
0:9c28f5905a1a
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:9c28f5905a1a 1 //-----------------------------------------------------------------
MikamiUitOpen 0:9c28f5905a1a 2 // 直流分除去用 IIR フィルタ
MikamiUitOpen 0:9c28f5905a1a 3 // u[n] = a1*u[n-1] + x[n]
MikamiUitOpen 0:9c28f5905a1a 4 // y[n] = g0*(u[n] - u[n-1])
MikamiUitOpen 0:9c28f5905a1a 5 //
MikamiUitOpen 0:9c28f5905a1a 6 // 2020/08/17, Copyright (c) 2020 MIKAMI, Naoki
MikamiUitOpen 0:9c28f5905a1a 7 //-----------------------------------------------------------------
MikamiUitOpen 0:9c28f5905a1a 8
MikamiUitOpen 0:9c28f5905a1a 9 #include "mbed.h"
MikamiUitOpen 0:9c28f5905a1a 10
MikamiUitOpen 0:9c28f5905a1a 11 #ifndef IIR_DC_CUT_HPP
MikamiUitOpen 0:9c28f5905a1a 12 #define IIR_DC_CUT_HPP
MikamiUitOpen 0:9c28f5905a1a 13 namespace Mikami
MikamiUitOpen 0:9c28f5905a1a 14 {
MikamiUitOpen 0:9c28f5905a1a 15 class IirDcCut
MikamiUitOpen 0:9c28f5905a1a 16 {
MikamiUitOpen 0:9c28f5905a1a 17 public:
MikamiUitOpen 0:9c28f5905a1a 18 // コンストラクタ
MikamiUitOpen 0:9c28f5905a1a 19 // a1 フィルタの係数
MikamiUitOpen 0:9c28f5905a1a 20 // g0 利得定数
MikamiUitOpen 0:9c28f5905a1a 21 IirDcCut(float a1, float g0)
MikamiUitOpen 0:9c28f5905a1a 22 : A1_(a1), G0_(g0), un1_(0) {}
MikamiUitOpen 0:9c28f5905a1a 23
MikamiUitOpen 0:9c28f5905a1a 24 // フィルタの実行
MikamiUitOpen 0:9c28f5905a1a 25 float Execute(float xn)
MikamiUitOpen 0:9c28f5905a1a 26 {
MikamiUitOpen 0:9c28f5905a1a 27 float un = A1_*un1_ + xn;
MikamiUitOpen 0:9c28f5905a1a 28 float yn = (un - un1_)*G0_;
MikamiUitOpen 0:9c28f5905a1a 29 un1_ = un;
MikamiUitOpen 0:9c28f5905a1a 30 return yn;
MikamiUitOpen 0:9c28f5905a1a 31 }
MikamiUitOpen 0:9c28f5905a1a 32
MikamiUitOpen 0:9c28f5905a1a 33 private:
MikamiUitOpen 0:9c28f5905a1a 34 const float A1_; // フィルタ係数
MikamiUitOpen 0:9c28f5905a1a 35 const float G0_; // 利得定数
MikamiUitOpen 0:9c28f5905a1a 36 float un1_; // 遅延器の値
MikamiUitOpen 0:9c28f5905a1a 37
MikamiUitOpen 0:9c28f5905a1a 38 // コピー・コンストラクタ,代入演算子の禁止のため
MikamiUitOpen 0:9c28f5905a1a 39 IirDcCut(const IirDcCut&);
MikamiUitOpen 0:9c28f5905a1a 40 IirDcCut& operator=(const IirDcCut&);
MikamiUitOpen 0:9c28f5905a1a 41 };
MikamiUitOpen 0:9c28f5905a1a 42 }
MikamiUitOpen 0:9c28f5905a1a 43 #endif // IIR_DC_CUT_HPP