Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

fir_decim.h

Go to the documentation of this file.
00001 // 
00002 // Copyright(c) 1993-1996 Tony Kirke
00003 // author="Tony Kirke" *
00004 /*
00005  * SPUC - Signal processing using C++ - A DSP library
00006  * 
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 #ifndef FIRD
00022 #define FIRD
00023 #include <fir.h>
00024 namespace SPUC {
00028 
00029 
00030 template <class Numeric> class fir_decim : public fir<Numeric>
00031 {
00032  public: 
00034         fir_decim<Numeric>(void) { }
00035         fir_decim<Numeric>(long n) : fir<Numeric>(n) {  }
00036         fir_decim<Numeric>(const char* file) { fir<Numeric>::read_taps(file); }
00037         
00038         void input(Numeric in) {
00039                 int i;                                           
00040                 // Update history of inputs
00041                 for (i=fir<Numeric>::num_taps-1;i>0;i--) fir<Numeric>::z[i] = fir<Numeric>::z[i-1];  
00042                 // Add new input
00043                 fir<Numeric>::z[0] = in;   
00044         }
00047         Numeric decim(void) {
00048                 // Perform FIR
00049                 Numeric output;
00050                 int i;
00051                 for (output=0,i=0;i<fir<Numeric>::num_taps;i++) output += fir<Numeric>::coeff[i]*fir<Numeric>::z[i];
00052                 return(output); 
00053         }
00054 
00055 };      
00056 } // namespace SPUC 
00057 #endif

Generated on Fri Sep 16 11:02:26 2005 for spuc by  doxygen 1.4.4