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

iir_hpc.h

Go to the documentation of this file.
00001 // 
00002 // Copyright(c) 1993-1996 Tony Kirke
00003 // author="Tony Kirke" *
00004 /* Permission to use, copy, modify, distribute and sell this software
00005  * and its documentation for any purpose is hereby granted without fee,
00006  * provided that the above copyright notice appear in all copies and
00007  * that both that copyright notice and this permission notice appear
00008  * in supporting documentation.  This software is provided "as is" 
00009  * without express or implied warranty.
00010 */
00011 #ifndef IIR1STHC
00012 #define IIR1STHC
00013 namespace SPUC {
00017 //
00024 template <class Numeric> class iir_hpc
00025 {
00026     protected:   
00027         double gain;                    
00028         double coeff;                    
00029         Numeric out;
00030         Numeric previous_out;
00031                 Numeric previous_in;
00032         
00033     public:
00034         iir_hpc(double A=0) {
00035                   set_coeff(A);
00036                   previous_in = previous_out = out = 0 ; 
00037                 }
00038                 void set_coeff(double A) { 
00039                   coeff=A;
00040                   gain=2.0/(1+coeff);
00041                 }
00043                 iir_hpc(const char* file)
00044                   {
00045                         FILE *iirf = fopen(file,"r"); 
00046                         fscanf(iirf,"%lf",&coeff);
00047                         fclose(iirf);
00048                         previous_in = previous_out = out = 0;
00049                         set_coeff(coeff);
00050                   }             
00052                 void print() {printf("IIR Coefficient gain = %lf\n",gain);}
00054                 Numeric clock(Numeric input) {
00056                   out += (input-coeff*previous_in);
00057                   previous_in = input;
00058                   return(gain*out);
00059                 }
00061                 void reset() {
00062                   previous_in = previous_out = out = 0;
00063                 }
00064 };       
00065 } // namespace SPUC
00066 #endif

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