00001 /* 00002 * SPUC - Signal processing using C++ - A DSP library 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2, or (at your option) 00007 * any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 #include "allpass_1.h" 00019 namespace SPUC { 00021 // This one uses the double type and default delay 1 00024 class double_allpass_iir 00025 { 00026 protected: 00027 allpass_1<double> A0,A1; 00028 delay<double> dly; 00029 long delay_size; 00030 00031 public: 00032 double_allpass_iir(double c0=0.25, double c1=0.75, long delay=1) 00033 : A0(c0,delay), A1(c1,delay), delay_size(delay) { 00034 dly.set_size(delay); 00035 } 00036 00037 00038 double clock(double input) { 00039 // Shift inputs by one time sample and place new sample into array 00040 double out0,out1; 00041 dly.input(input); 00042 out0 = A0.clock(input); 00043 out1 = A1.clock(dly.check(delay_size/2)); 00044 return(0.5*(out0 + out1)); 00045 // Complimentary filter return(0.5*(out0 - out1)); 00046 } 00047 }; 00048 } // namespace SPUC