The experiment using this program is introduced on "Interface" No.2, CQ publishing Co.,Ltd, 2015. 本プログラムを使った実験は,CQ出版社のインターフェース 2015年2月号で紹介しています.
Dependencies: DSProcessingIO mbed
Biquad.hpp
- Committer:
- CQpub0Mikami
- Date:
- 2014-07-15
- Revision:
- 0:398107c96b1b
File content as of revision 0:398107c96b1b:
//-------------------------------------------------------------- // Biquad filter for IIR filter of cascade structure // Copyright (c) 2014 MIKAMI, Naoki, 2014/07/15 //-------------------------------------------------------------- #ifndef IIR_BIQUAD_HPP #define IIR_BIQUAD_HPP #include "mbed.h" namespace Mikami { // 2nd order IIR filter class Biquad { public: struct Coefs { float a1, a2, b1, b2; }; Biquad() {} // Default constructore Biquad(const Coefs ck) : a1_(ck.a1), a2_(ck.a2), b1_(ck.b1), b2_(ck.b2) { Clear(); } float Execute(float xn) { float un = xn + a1_*un1_ + a2_*un2_; float yn = un + b1_*un1_ + b2_*un2_; un2_ = un1_; un1_ = un; return yn; } void Clear() { un1_ = un2_ = 0; } private: float a1_, a2_, b1_, b2_; float un1_, un2_; Biquad(const Biquad&); }; } #endif // IIR_BIQUAD_HPP