The experiment using this program is introduced on "Interface" No.2, CQ publishing Co.,Ltd, 2015. 本プログラムを使った実験は,CQ出版社のインターフェース 2015年2月号で紹介しています.

Dependencies:   DSProcessingIO mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IIR_Cascade.hpp Source File

IIR_Cascade.hpp

00001 //--------------------------------------------------------------
00002 // IIR filter ---- Cascade structure
00003 // Copyright (c) 2014 MIKAMI, Naoki, 2014/07/15
00004 //--------------------------------------------------------------
00005 
00006 #ifndef IIR_CASCADE_HPP
00007 #define IIR_CASCADE_HPP
00008 
00009 #include "mbed.h"
00010 #include "Biquad.hpp"
00011 
00012 namespace Mikami
00013 {
00014     // IIR filter -- Cascade structure
00015     template<int order> class IirCascade
00016     {
00017     private:
00018         Biquad hk_[order];  // Elements of cascade structure
00019         const float G0_;    // gain factor
00020  
00021         IirCascade(const IirCascade&);
00022         IirCascade& operator=(const IirCascade&);
00023  
00024     public:
00025         IirCascade(float g0, const Biquad::Coefs ck[])
00026                   : G0_(g0)
00027         {
00028             for (int k=0; k<order; k++)
00029                 hk_[k] = Biquad(ck[k]);
00030         }
00031 
00032         float Execute(float xn)
00033         {
00034             float yn = G0_*xn;
00035             for (int k=0; k<order; k++)
00036                 yn = hk_[k].Execute(yn);
00037                 
00038             return yn;
00039         }
00040         
00041         void Clear()
00042         {
00043             for (int k=0; k<order; k++)
00044                 hk_[k].Clear();
00045         }
00046     };
00047 }
00048 #endif  // IIR_CASCADE_HPP
00049