FFT_Wrapper.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CSL_FFT_WRAPPER_H
00022 #define CSL_FFT_WRAPPER_H
00023
00024
00025
00026
00027
00028
00029 #include "CSL_Core.h"
00030
00031 #ifdef USE_FFTW
00032 #include <fftw3.h>
00033 #define FFTWrapper FFTW_Wrapper // which FFT wrapper class to use?
00034 #define FFTWF_FLAGS FFTW_MEASURE // or use FFTW_ESTIMATE; FFTW_PRESERVE_INPUT not necessary
00035 #endif
00036
00037 #ifdef USE_FFTREAL
00038 #include <FFTReal.h>
00039 #define FFTWrapper FFTR_Wrapper
00040 #endif
00041
00042 #ifdef USE_KISSFFT
00043 #include <kiss_fft.h>
00044 #define FFTWrapper KISSFFT_Wrapper
00045 #endif
00046
00047 namespace csl {
00048
00050
00051 typedef enum {
00052 CSL_FFT_REAL = 0,
00053 CSL_FFT_COMPLEX,
00054 CSL_FFT_MAGPHASE
00055 } CSL_FFTType;
00056
00058
00059 typedef enum {
00060 CSL_FFT_FORWARD = 0,
00061 CSL_FFT_INVERSE
00062 } CSL_FFTDir;
00063
00067
00068 class Abst_FFT_W {
00069 public:
00070 Abst_FFT_W(unsigned size, CSL_FFTType type = CSL_FFT_REAL, CSL_FFTDir forward = CSL_FFT_FORWARD)
00071 : mSize(size), mCSize((size / 2) + 1), mType(type), mDirection(forward) { };
00072
00073 ~Abst_FFT_W() { };
00074
00076 virtual void nextBuffer(Buffer & in, Buffer & out) throw (CException) = 0;
00077
00078 unsigned mSize;
00079 unsigned mCSize;
00080 protected:
00081 CSL_FFTType mType;
00082 CSL_FFTDir mDirection;
00083 };
00084
00085
00086
00087
00088
00089 #ifdef USE_FFTW
00090
00091
00092 class FFTW_Wrapper : public Abst_FFT_W {
00093 public:
00094 FFTW_Wrapper(unsigned size, CSL_FFTType type = CSL_FFT_REAL, CSL_FFTDir forward = CSL_FFT_FORWARD);
00095 ~FFTW_Wrapper();
00097 void nextBuffer(Buffer & in, Buffer & out) throw (CException);
00098
00099 private:
00100 SampleBuffer mInBuf;
00101 SampleBuffer mSampBuf;
00102 fftwf_complex *mSpectBuf;
00103 fftwf_plan mPlan;
00104 };
00105
00106 #endif
00107
00108
00109
00110
00111
00112 #ifdef USE_FFTREAL
00113
00114
00115 class FFTR_Wrapper : public Abst_FFT_W {
00116 public:
00117 FFTR_Wrapper(unsigned size, CSL_FFTType type = CSL_FFT_REAL, CSL_FFTDir forward = CSL_FFT_FORWARD);
00118 ~FFTR_Wrapper();
00120 void nextBuffer(Buffer & in, Buffer & out) throw (CException);
00121
00122 private:
00123 SampleBuffer mTempBuf;
00124 FFTReal mFFT;
00125 };
00126
00127 #endif
00128
00129
00130
00131
00132
00133 #ifdef USE_KISSFFT
00134
00135
00136 class KISSFFT_Wrapper : public Abst_FFT_W {
00137 public:
00138 KISSFFT_Wrapper(unsigned size, CSL_FFTType type = CSL_FFT_REAL, CSL_FFTDir forward = CSL_FFT_FORWARD);
00139 ~KISSFFT_Wrapper();
00141 void nextBuffer(Buffer & in, Buffer & out) throw (CException);
00142
00143 private:
00144 SampleBuffer mTempBuf;
00145 kiss_fft_cfg mFFT;
00146 SampleComplexVector inBuf, outBuf;
00147 };
00148
00149 #endif
00150
00151 }
00152
00153 #endif