FFT_base.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
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 #ifndef _FFT_base_
00024 #define _FFT_base_
00025 
00026 #include <typeinfo> // for bad_cast definition
00027 #include "Processing.hxx"
00028 #include "AudioInPort.hxx"
00029 #include "OutPort.hxx"
00030 #include <string>
00031 #include "FFTConfig.hxx"
00032 #include "SpecTypeFlags.hxx"
00033 #include "Spectrum.hxx"
00034 
00035 namespace CLAM {
00036 
00037     class Storage;
00038     class ProcessingConfig;
00039     class Audio;
00040     class Spectrum;
00041 
00043     class FFT_base: public Processing
00044     {
00045     protected:
00046 
00048         static SpecTypeFlags mComplexflags;
00049 
00051         Spectrum mComplexSpectrum;
00052         
00054         FFTConfig mConfig;
00056         int mSize;
00057 
00058         /* FFT possible execution states.
00059          */
00060         typedef enum {
00061                 sComplex, // We just need to write the complex array.
00062                 sComplexSync, // We write the complex array and synchronize.
00063                 sOther // The complex array is not present.
00064         } FFTState;
00065 
00067         FFTState mState;
00068         
00075         FFTState mBackupState;
00076 
00077         AudioInPort     mInput;
00078         OutPort<Spectrum> mOutput;
00079 
00081         TData* fftbuffer;
00082 
00083         // Control change callback function
00084         void ChangeSize(int n);
00085         int GetSize() {return mSize;}
00086 
00087         virtual bool ConcreteConfigure(const ProcessingConfig&) = 0;
00088 
00089     public:
00090 
00091         FFT_base();
00092         virtual ~FFT_base();
00093 
00096         const ProcessingConfig &GetConfig() const { return mConfig;}
00097         
00100         virtual bool Do(void) = 0;
00101 
00107         virtual bool Do(const Audio& in, Spectrum &out)= 0;
00108 
00109         // Input/Output configuration methods
00110 
00112         bool SetPrototypes(const Audio& in,const Spectrum &out);
00113 
00115         bool SetPrototypes() {return false;}
00116 
00118         bool UnsetPrototypes();
00119 
00120         void CheckTypes(const Audio& in, const Spectrum &out) const;
00121 
00122 
00123         // Enable/Disable methods. Maybe we should not be deriving
00124         // these ones in FFT subclasses. (FFT implementations will
00125         // probably be always memoryless.
00126 
00127         virtual bool MayDisableExecution() const {return false;}
00128 
00129         virtual bool DisableExecution() {return false;}
00130 
00131         virtual bool EnableExecution() {return false;}
00132 
00133         // Output conversions
00134 
00135         virtual void ToComplex(Spectrum &out) = 0;
00136 
00137         virtual void ToOther(Spectrum &out);            
00138 
00139     };
00140 
00141 
00142 };//namespace CLAM
00143 
00144 
00145 #endif // _FFT_base_
00146 
Generated by  doxygen 1.6.3