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

iir_2ndhpf.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 IIR_2NDHPF
00022 #define IIR_2NDHPF
00023 namespace SPUC {
00026 //
00035 template <class Numeric> class iir_2ndhpf
00036 {
00037     protected:   
00038         Numeric b0,b1,b2;                    
00039         Numeric a1,a2;
00040         Numeric in[3];
00041         Numeric out[3]; 
00042         
00043     public:
00044         iir_2ndhpf(Numeric A, Numeric B) {
00045                         double g = 1.0/(1.0+A+B);
00046                         b0 = g;
00047                         b1 = -2*g;
00048                         b2 = g;
00049                         a1 = 2*(A-1)*g;
00050                         a2 = (1-B+A)*g;
00051                 in[0] = in[1] = in[2] = out[2] = out[1] = out[0] = 0 ; }
00052         void reset() {
00053                 in[0] = in[1] = in[2] = out[2] = out[1] = out[0] = 0 ; } 
00055 void print() {
00056     printf("IIR Coefficients B0 = %lf, B1 =  %lf, B2 = %lf",b0,b1,b2);
00057     printf(" A0 = 1, A1 = %lf, A2 = %lf\n",a1,a2);
00058 }
00060 Numeric clock(Numeric input) {
00061         // Shift inputs by one time sample and place new sample into array
00062         in[0] = in[1];
00063         in[1] = in[2];
00064         in[2] = input;
00065         // Shift previous outputs and calculate new output */
00066         out[0] = out[1];
00067         out[1] = out[2];
00068         out[2] = b0*in[2] + b1*in[1] + b2*in[0] - a1*out[1] - a2*out[0];
00069         return(out[2]);
00070 }
00071 };                                               
00072 } // namespace SPUC 
00073 #endif

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