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

iir_comb.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_COMB
00022 #define IIR_COMB
00023 #include <delay.h>
00024 namespace SPUC {
00029 template <class Numeric> class iir_comb {
00030  protected:   
00031         double in_gain;                    
00032         double acc_gain;                    
00033         Numeric out;
00034         delay<Numeric> dly;
00035         long delay_size;
00036         Numeric previous_out;
00037         Numeric previous_in;
00038         
00039  public:
00040         iir_comb(double A=0, long delay=2) : acc_gain(A), in_gain(1-A),
00041                 delay_size(delay) {
00042                 dly.set_size(delay);
00043                 previous_in = previous_out = out = 0 ; 
00044         }
00045         void init(double A, long delay) { 
00046                 in_gain=1-A; acc_gain = A;
00047                 delay_size = delay;
00048                 dly.set_size(delay);
00049         }
00050 
00051         void set_coeff(double A) { in_gain=1-A; acc_gain = A;}
00053         Numeric clock(Numeric input) {
00054                 // Shift previous outputs and calculate new output
00055                 out = acc_gain*previous_out + in_gain*input;
00056                 previous_out = dly.input(out);
00057                 return(out);
00058         }
00060         void reset() {
00061                 previous_in = previous_out = out = 0;
00062                 dly.reset();
00063         }
00064 };                                               
00065 } // namespace SPUC 
00066 #endif

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