00001 // 00002 // author="Tony Kirke" 00003 // Copyright(c) 1993-1996 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 ALLPASS_IIR 00022 #define ALLPASS_IIR 00023 #include "allpass_1.h" 00024 namespace SPUC { 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 template <class Numeric> class allpass_iir 00043 { 00044 protected: 00045 allpass_1<Numeric> A0,A1; 00046 delay<Numeric> dly; 00047 long delay_size; 00048 00049 public: 00050 allpass_iir(Numeric c0, Numeric c1, long delay=2) 00051 : A0(c0,delay), A1(c1,delay), delay_size(delay) 00052 { 00053 dly.set_size(delay); 00054 } 00056 void reset() { dly.reset(); A0.reset(), A1.reset() } 00057 00059 Numeric clock(Numeric input) { 00060 Numeric out0,out1; 00061 00062 dly.input(input); 00063 out0 = A0.clock(input); 00064 out1 = A1.clock(dly.check(delay_size/2)); 00065 return(0.5*(out0 + out1)); 00066 // Complimentary filter return(0.5*(out0 - out1)); 00067 } 00068 }; 00069 } // namespace SPUC 00070 #endif