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

FIRMultiRate.cc

Go to the documentation of this file.
00001 /*
00002 
00003     Base class for FIR 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/FIRMultiRate.hh"
00032 
00033 /*#include "Dec2Filter2.h"
00034 #include "Dec3Filter2.h"
00035 #include "Dec4Filter2.h"
00036 #include "Dec8Filter2.h"
00037 #include "Dec2hpFilter2.h"
00038 #include "Dec3hpFilter2.h"
00039 #include "Dec4hpFilter2.h"
00040 #include "Dec8hpFilter2.h"*/
00041 #include "Dec2Filter3.h"
00042 #include "Dec3Filter3.h"
00043 #include "Dec4Filter3.h"
00044 #include "Dec8Filter3.h"
00045 #include "Dec2hpFilter3.h"
00046 #include "Dec3hpFilter3.h"
00047 #include "Dec4hpFilter3.h"
00048 #include "Dec8hpFilter3.h"
00049 
00050 
00051 clFIRMultiRate::clFIRMultiRate ()
00052 {
00053 }
00054 
00055 
00056 clFIRMultiRate::~clFIRMultiRate ()
00057 {
00058     Uninitialize();
00059 }
00060 
00061 
00062 bool clFIRMultiRate::Initialize (long lFactorP, const float *fpNullPtr,
00063     bool bHighPass)
00064 {
00065     lFactor = lFactorP;
00066     switch (lFactor)
00067     {
00068         case 2:
00069             if (!bHighPass)
00070             {
00071                 fGain = fDec2FilterGain;
00072                 FIR.FIRAllocate(fpDec2FilterCoeffs, lDec2FilterLen);
00073             }
00074             else
00075             {
00076                 fGain = fDec2hpFilterGain;
00077                 FIR.FIRAllocate(fpDec2hpFilterCoeffs, lDec2hpFilterLen);
00078             }
00079             break;
00080         case 3:
00081             if (!bHighPass)
00082             {
00083                 fGain = fDec3FilterGain;
00084                 FIR.FIRAllocate(fpDec3FilterCoeffs, lDec3FilterLen);
00085             }
00086             else
00087             {
00088                 fGain = fDec3hpFilterGain;
00089                 FIR.FIRAllocate(fpDec3hpFilterCoeffs, lDec3hpFilterLen);
00090             }
00091             break;
00092         case 4:
00093             if (!bHighPass)
00094             {
00095                 fGain = fDec4FilterGain;
00096                 FIR.FIRAllocate(fpDec4FilterCoeffs, lDec4FilterLen);
00097             }
00098             else
00099             {
00100                 fGain = fDec4hpFilterGain;
00101                 FIR.FIRAllocate(fpDec4hpFilterCoeffs, lDec4hpFilterLen);
00102             }
00103             break;
00104         case 8:
00105             if (!bHighPass)
00106             {
00107                 fGain = fDec8FilterGain;
00108                 FIR.FIRAllocate(fpDec8FilterCoeffs, lDec8FilterLen);
00109             }
00110             else
00111             {
00112                 fGain = fDec8hpFilterGain;
00113                 FIR.FIRAllocate(fpDec8hpFilterCoeffs, lDec8hpFilterLen);
00114             }
00115             break;
00116         default:
00117             return false;
00118     }
00119     return true;
00120 }
00121 
00122 
00123 bool clFIRMultiRate::Initialize (long lFactorP, const double *dpNullPtr,
00124     bool bHighPass)
00125 {
00126     lFactor = lFactorP;
00127     switch (lFactor)
00128     {
00129         case 2:
00130             if (!bHighPass)
00131             {
00132                 dGain = dDec2FilterGain;
00133                 FIR.FIRAllocate(dpDec2FilterCoeffs, lDec2FilterLen);
00134             }
00135             else
00136             {
00137                 dGain = dDec2hpFilterGain;
00138                 FIR.FIRAllocate(dpDec2hpFilterCoeffs, lDec2hpFilterLen);
00139             }
00140             break;
00141         case 3:
00142             if (!bHighPass)
00143             {
00144                 dGain = dDec3FilterGain;
00145                 FIR.FIRAllocate(dpDec3FilterCoeffs, lDec3FilterLen);
00146             }
00147             else
00148             {
00149                 dGain = dDec3hpFilterGain;
00150                 FIR.FIRAllocate(dpDec3hpFilterCoeffs, lDec3hpFilterLen);
00151             }
00152             break;
00153         case 4:
00154             if (!bHighPass)
00155             {
00156                 dGain = dDec4FilterGain;
00157                 FIR.FIRAllocate(dpDec4FilterCoeffs, lDec4FilterLen);
00158             }
00159             else
00160             {
00161                 dGain = dDec4hpFilterGain;
00162                 FIR.FIRAllocate(dpDec4hpFilterCoeffs, lDec4hpFilterLen);
00163             }
00164             break;
00165         case 8:
00166             if (!bHighPass)
00167             {
00168                 dGain = dDec8FilterGain;
00169                 FIR.FIRAllocate(dpDec8FilterCoeffs, lDec8FilterLen);
00170             }
00171             else
00172             {
00173                 dGain = dDec8hpFilterGain;
00174                 FIR.FIRAllocate(dpDec8hpFilterCoeffs, lDec8hpFilterLen);
00175             }
00176             break;
00177         default:
00178             return false;
00179     }
00180     return true;
00181 }
00182 
00183 
00184 void clFIRMultiRate::Uninitialize ()
00185 {
00186     FIR.FIRFree();
00187 }

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