![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
The experiment using this program is introduced on "Interface" No.2, CQ publishing Co.,Ltd, 2015. 本プログラムを使った実験は,CQ出版社のインターフェース 2015年2月号で紹介しています.
Dependencies: DSProcessingIO mbed
Diff: Biquad.hpp
- Revision:
- 0:398107c96b1b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Biquad.hpp Tue Jul 15 08:58:36 2014 +0000 @@ -0,0 +1,45 @@ +//-------------------------------------------------------------- +// 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