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

Dependencies:   DSProcessingIO mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FirBaseClass.hpp Source File

FirBaseClass.hpp

00001 //--------------------------------------------------------------
00002 // Virtual base class for FIR filter
00003 // Copyright (c) 2014 MIKAMI, Naoki, 2014/06/22
00004 //--------------------------------------------------------------
00005 
00006 #ifndef FIR_BASE_HPP
00007 #define FIR_BASE_HPP
00008 
00009 #include "mbed.h"
00010 
00011 namespace Mikami
00012 {
00013     template<int order> class FirBase
00014     {
00015     private:
00016         FirBase(const FirBase&);
00017         FirBase& operator=(const FirBase&);
00018     protected:
00019         const float *const hm_; // pointer for filter coefficients
00020         float xn_[order+1];     // buffer for inputs
00021 
00022         // Constructor
00023         FirBase(const float hk[]) : hm_(hk) { Clear(); }
00024         
00025         // Execute filter
00026         virtual float Execute(float xin) = 0;
00027 
00028         // Move signals in xn_[]
00029         void Move()
00030         {
00031             for (int k=order; k>0; k--)
00032                 xn_[k] = xn_[k-1];  // move input signals
00033         }
00034     public:
00035         void Clear()
00036         {
00037             for (int k=0; k<=order; k++) xn_[k] = 0.0;
00038         }
00039     };
00040 }
00041 #endif  // FIR_BASE_HPP