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

FIRDecimator.cc

Go to the documentation of this file.
00001 /*
00002 
00003     FIR Decimation class
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/FIRDecimator.hh"
00032 
00033 
00034 clFIRDecimator::clFIRDecimator ()
00035 {
00036 }
00037 
00038 
00039 clFIRDecimator::~clFIRDecimator ()
00040 {
00041     Uninitialize();
00042 }
00043 
00044 
00045 void clFIRDecimator::Uninitialize ()
00046 {
00047     DecBuf.Free();
00048     clFIRMultiRate::Uninitialize();
00049 }
00050 
00051 
00052 void clFIRDecimator::Put (const float *fpSrcData, long lSrcCount)
00053 {
00054     InBuf.Put(fpSrcData, lSrcCount);
00055 }
00056 
00057 
00058 void clFIRDecimator::Put (const double *dpSrcData, long lSrcCount)
00059 {
00060     InBuf.Put(dpSrcData, lSrcCount);
00061 }
00062 
00063 
00064 bool clFIRDecimator::Get (float *fpDestData, long lDestCount)
00065 {
00066     long lWorkCount;
00067     float *fpDecBuf;
00068 
00069     lWorkCount = lDestCount * lFactor;
00070     fpDecBuf = (float *) DecBuf.Size(lWorkCount * sizeof(float));
00071     if (!InBuf.Get(fpDecBuf, lWorkCount))
00072         return false;
00073     FIR.FIRFilter(fpDecBuf, lWorkCount);
00074     DSP.Decimate(fpDestData, fpDecBuf, lFactor, lWorkCount);
00075     DSP.Mul(fpDestData, fGain, lDestCount);
00076     return true;
00077 }
00078 
00079 
00080 bool clFIRDecimator::Get (double *dpDestData, long lDestCount)
00081 {
00082     long lWorkCount;
00083     double *dpDecBuf;
00084 
00085     lWorkCount = lDestCount * lFactor;
00086     dpDecBuf = (double *) DecBuf.Size(lWorkCount * sizeof(double));
00087     if (!InBuf.Get(dpDecBuf, lWorkCount))
00088         return false;
00089     FIR.FIRFilter(dpDecBuf, lWorkCount);
00090     DSP.Decimate(dpDestData, dpDecBuf, lFactor, lWorkCount);
00091     DSP.Mul(dpDestData, dGain, lDestCount);
00092     return true;
00093 }

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