Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FFTMultiRate.cc

Go to the documentation of this file.
00001 /*
00002 
00003     Base class for FFT based multirate filters
00004     Copyright (C) 2000-2003 Jussi Laako
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 */
00021 
00022 
00023 #include <stdio.h>
00024 #ifdef USE_INTEL_MATH
00025     #include <mathimf.h>
00026 #else
00027     #include <math.h>
00028 #endif
00029 #include <float.h>
00030 
00031 #include "dsp/FFTMultiRate.hh"
00032 
00033 
00034 clFFTMultiRate::clFFTMultiRate ()
00035 {
00036     bInitialized = false;
00037 }
00038 
00039 
00040 clFFTMultiRate::~clFFTMultiRate ()
00041 {
00042     if (bInitialized) Uninitialize();
00043 }
00044 
00045 
00046 bool clFFTMultiRate::Initialize (long lFactorP, long lFiltSize, 
00047     const float *fpNullPtr, bool bHighPass)
00048 {
00049     float fCorner;
00050     float fPassBand;
00051     float fStopBand;
00052 
00053     if (bInitialized) Uninitialize();
00054     lFilterSize = abs((int) lFiltSize);
00055     lFactor = lFactorP;
00056     fCorner = 1.0f / (float) lFactor;
00057     if (lFiltSize <= 0)
00058     {
00059         if (!bHighPass)
00060         {
00061             fPassBand = fCorner * (1.0f - FFTMULTIRATE_DELTAOMEGA / 2.0f);
00062             fStopBand = fCorner * (1.0f + FFTMULTIRATE_DELTAOMEGA / 2.0f);
00063             Filter.InitializeLP(fPassBand, fStopBand, 
00064                 FFTMULTIRATE_RIPPLERATIO,
00065                 FFTMULTIRATE_OVERLAP);
00066         }
00067         else
00068         {
00069             fPassBand = fCorner * (1.0f + FFTMULTIRATE_DELTAOMEGA / 2.0f);
00070             fStopBand = fCorner * (1.0f - FFTMULTIRATE_DELTAOMEGA / 2.0f);
00071             Filter.InitializeHP(fPassBand, fStopBand, 
00072                 FFTMULTIRATE_RIPPLERATIO,
00073                 FFTMULTIRATE_OVERLAP);
00074         }
00075     }
00076     else
00077     {
00078         Filter.Initialize(lFilterSize, fpNullPtr);
00079         if (!bHighPass)
00080             Filter.DesignLP(&fCorner);
00081         else
00082             Filter.DesignHP(&fCorner);
00083     }
00084     return true;
00085 }
00086 
00087 
00088 bool clFFTMultiRate::Initialize (long lFactorP, long lFiltSize,
00089     const double *dpNullPtr, bool bHighPass)
00090 {
00091     double dCorner;
00092     double dPassBand;
00093     double dStopBand;
00094 
00095     if (bInitialized) Uninitialize();
00096     lFilterSize = abs((int) lFiltSize);
00097     lFactor = lFactorP;
00098     dCorner = 1.0 / (double) lFactor;
00099     if (lFiltSize <= 0)
00100     {
00101         if (!bHighPass)
00102         {
00103             dPassBand = dCorner * (1.0 - FFTMULTIRATE_DELTAOMEGA / 2.0);
00104             dStopBand = dCorner * (1.0 + FFTMULTIRATE_DELTAOMEGA / 2.0);
00105             Filter.InitializeLP(dPassBand, dStopBand, 
00106                 (double) FFTMULTIRATE_RIPPLERATIO,
00107                 (double) FFTMULTIRATE_OVERLAP);
00108         }
00109         else
00110         {
00111             dPassBand = dCorner * (1.0 + FFTMULTIRATE_DELTAOMEGA / 2.0);
00112             dStopBand = dCorner * (1.0 - FFTMULTIRATE_DELTAOMEGA / 2.0);
00113             Filter.InitializeHP(dPassBand, dStopBand, 
00114                 (double) FFTMULTIRATE_RIPPLERATIO,
00115                 (double) FFTMULTIRATE_OVERLAP);
00116         }
00117     }
00118     else
00119     {
00120         Filter.Initialize(lFilterSize, dpNullPtr);
00121         if (!bHighPass)
00122             Filter.DesignLP(&dCorner);
00123         else
00124             Filter.DesignHP(&dCorner);
00125     }
00126     return true;
00127 }
00128 
00129 
00130 void clFFTMultiRate::Uninitialize ()
00131 {
00132     Filter.Uninitialize();
00133     bInitialized = false;
00134 }

Generated on Tue Mar 2 19:46:44 2004 for libDSP by doxygen 1.3.6