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

FlipBand.cc

Go to the documentation of this file.
00001 /*
00002 
00003     Class for flipping odd frequency bands
00004     Copyright (C) 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 "dsp/FlipBand.hh"
00024 
00025 
00026 clFlipBand::clFlipBand ()
00027 {
00028     bInitialized = false;
00029     lBlockSize = 0;
00030 }
00031 
00032 
00033 clFlipBand::~clFlipBand ()
00034 {
00035     if (bInitialized)
00036         Uninitialize();
00037 }
00038 
00039 
00040 void clFlipBand::Initialize (long lTransformSize, const float *fpNullPtr)
00041 {
00042     lBlockSize = lTransformSize;
00043     lCBlockSize = lTransformSize / 2 + 1;
00044     DSP.FFTInitialize(lTransformSize, true);
00045     Proc.Size(lBlockSize * sizeof(float));
00046     CProc.Size(lCBlockSize * sizeof(stSCplx));
00047     bInitialized = true;
00048 }
00049 
00050 
00051 void clFlipBand::Initialize (long lTransformSize, const double *dpNullPtr)
00052 {
00053     lBlockSize = lTransformSize;
00054     lCBlockSize = lTransformSize / 2 + 1;
00055     DSP.FFTInitialize(lTransformSize, true);
00056     Proc.Size(lBlockSize * sizeof(double));
00057     CProc.Size(lCBlockSize * sizeof(stDCplx));
00058     bInitialized = true;
00059 }
00060 
00061 
00062 void clFlipBand::Uninitialize ()
00063 {
00064     if (bInitialized)
00065     {
00066         DSP.FFTUninitialize();
00067         Clear();
00068         Proc.Free();
00069         CProc.Free();
00070         bInitialized = false;
00071     }
00072 }
00073 
00074 
00075 void clFlipBand::Put (const float *fpSrc, long lCount)
00076 {
00077     float *fpProc;
00078     stpSCplx spCProc;
00079 
00080     fpProc = Proc;
00081     spCProc = CProc;
00082     InBuf.Put(fpSrc, lCount);
00083     while (InBuf.Get(fpProc, lBlockSize))
00084     {
00085         DSP.FFTi(spCProc, fpProc);
00086         DSP.Reverse(spCProc, lCBlockSize);
00087         DSP.IFFTo(fpProc, spCProc);
00088         OutBuf.Put(fpProc, lBlockSize);
00089     }
00090 }
00091 
00092 
00093 void clFlipBand::Put (const double *dpSrc, long lCount)
00094 {
00095     double *dpProc;
00096     stpDCplx spCProc;
00097 
00098     dpProc = Proc;
00099     spCProc = CProc;
00100     InBuf.Put(dpSrc, lCount);
00101     while (InBuf.Get(dpProc, lBlockSize))
00102     {
00103         DSP.FFTi(spCProc, dpProc);
00104         DSP.Reverse(spCProc, lCBlockSize);
00105         DSP.IFFTo(dpProc, spCProc);
00106         OutBuf.Put(dpProc, lBlockSize);
00107     }
00108 }
00109 
00110 
00111 bool clFlipBand::Get (float *fpDest, long lCount)
00112 {
00113     return OutBuf.Get(fpDest, lCount);
00114 }
00115 
00116 
00117 bool clFlipBand::Get (double *dpDest, long lCount)
00118 {
00119     return OutBuf.Get(dpDest, lCount);
00120 }
00121 
00122 
00123 void clFlipBand::Clear ()
00124 {
00125     InBuf.Clear();
00126     OutBuf.Clear();
00127 }

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