![](/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: IIR_Cascade.hpp
- Revision:
- 0:398107c96b1b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IIR_Cascade.hpp Tue Jul 15 08:58:36 2014 +0000 @@ -0,0 +1,49 @@ +//-------------------------------------------------------------- +// IIR filter ---- Cascade structure +// Copyright (c) 2014 MIKAMI, Naoki, 2014/07/15 +//-------------------------------------------------------------- + +#ifndef IIR_CASCADE_HPP +#define IIR_CASCADE_HPP + +#include "mbed.h" +#include "Biquad.hpp" + +namespace Mikami +{ + // IIR filter -- Cascade structure + template<int order> class IirCascade + { + private: + Biquad hk_[order]; // Elements of cascade structure + const float G0_; // gain factor + + IirCascade(const IirCascade&); + IirCascade& operator=(const IirCascade&); + + public: + IirCascade(float g0, const Biquad::Coefs ck[]) + : G0_(g0) + { + for (int k=0; k<order; k++) + hk_[k] = Biquad(ck[k]); + } + + float Execute(float xn) + { + float yn = G0_*xn; + for (int k=0; k<order; k++) + yn = hk_[k].Execute(yn); + + return yn; + } + + void Clear() + { + for (int k=0; k<order; k++) + hk_[k].Clear(); + } + }; +} +#endif // IIR_CASCADE_HPP +