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 #ifndef CSD_ALLPASS_HALFBAND 00019 #define CSD_ALLPASS_HALFBAND 00020 #include <allpass_1aq1.h> 00021 #include <allpass_1aq2.h> 00022 namespace SPUC { 00025 // so that the overall H(z) is \f$ H(z) = G(z,a0)*z^{-1} + G(z,a1) \f$ 00026 // <p>The combination of these two allpass functions result 00027 // in a lowpass/highpass complementary pair. This class only 00028 // uses the low pass filter. 00031 class csd_allpass_halfband 00032 { 00033 public: 00034 char ready; 00035 protected: 00036 allpass_1aq1 A0; 00037 allpass_1aq2 A1; 00038 long out0,out1; 00039 00040 public: 00041 csd_allpass_halfband() { ready = 1; } 00042 00043 00044 long clock(long input) { 00045 // Shift inputs by one time sample and place new sample into array 00046 00047 ready = !ready; 00048 if (ready) { 00049 out0 = A0.clock(input); 00050 } else { 00051 out1 = A1.clock(input); 00052 } 00053 if (ready) return(out0 + out1); 00054 else return(0); // to indicate that this sample is not calculated 00055 // Complimentary filter return(0.5*(out0 - out1)); 00056 } 00057 }; 00058 } // namespace SPUC 00059 00060 #endif 00061