ese 519 include files

Dependents:   PROJECT_3D_AUDIO COG4050_adxl355_tilt COG4050_adxl355_tilt COG4050_adxl355_tilt_4050

Committer:
niv17
Date:
Tue Apr 07 21:09:51 2015 +0000
Revision:
0:5347612e39a3
april_7 _ sonic start

Who changed what in which revision?

UserRevisionLine numberNew contents of line
niv17 0:5347612e39a3 1 // fft.h - declaration of class
niv17 0:5347612e39a3 2 // of fast Fourier transform - FFT
niv17 0:5347612e39a3 3 //
niv17 0:5347612e39a3 4 // The code is property of LIBROW
niv17 0:5347612e39a3 5 // You can use it on your own
niv17 0:5347612e39a3 6 // When utilizing credit LIBROW site
niv17 0:5347612e39a3 7
niv17 0:5347612e39a3 8 #ifndef FFT_H
niv17 0:5347612e39a3 9 #define FFT_H
niv17 0:5347612e39a3 10
niv17 0:5347612e39a3 11 //#include "complex.h"
niv17 0:5347612e39a3 12 #include "complextype.h"
niv17 0:5347612e39a3 13 #include <string>
niv17 0:5347612e39a3 14
niv17 0:5347612e39a3 15 class CFFT
niv17 0:5347612e39a3 16 {
niv17 0:5347612e39a3 17 public:
niv17 0:5347612e39a3 18 //Convolution functions
niv17 0:5347612e39a3 19 //NFFT is the FFT size (will be modified if invalid!), nSIG is the size for the input, NFIL is the size of the filter
niv17 0:5347612e39a3 20 //Zero padding is automatically taken care of in the convolution function.
niv17 0:5347612e39a3 21 //T means the function returns result in time domain; F is the result in the frequency domain.
niv17 0:5347612e39a3 22 static Complex* convolutionF(const Complex *input,const Complex *filter, long nSIG, long NFIL, long &NFFT);
niv17 0:5347612e39a3 23 static Complex* convolutionT(const Complex *input,const Complex *filter, long nSIG, long NFIL, long &NFFT);
niv17 0:5347612e39a3 24 static Complex* stereoConvMonoInputF(const Complex *input, const Complex *filterLeft, const Complex *filterRight, long nSIG, long NFILL, long NFILR, long &NFFT);
niv17 0:5347612e39a3 25 static Complex* stereoConvMonoInputT(const Complex *input, const Complex *filterLeft, const Complex *filterRight, long nSIG,long NFILL, long NFILR, long &NFFT);
niv17 0:5347612e39a3 26 static Complex* stereoConvStereoInputF(const Complex *input, const Complex *filterLeft, const Complex *filterRight, long nSIG, long NFILL, long NFILR, long &NFFT);
niv17 0:5347612e39a3 27 static Complex* stereoConvStereoInputT(const Complex *input, const Complex *filterLeft, const Complex *filterRight, long nSIG, long NFILL, long NFILR, long &NFFT);
niv17 0:5347612e39a3 28
niv17 0:5347612e39a3 29
niv17 0:5347612e39a3 30 //storing the an array into a text file
niv17 0:5347612e39a3 31 //filename is the file name you want to store the data into
niv17 0:5347612e39a3 32 //datatype represents the data you wanna store: real/real+imag/amplitude
niv17 0:5347612e39a3 33 static void storingData(Complex *data, int NFFT, std::string temp, char datatype);
niv17 0:5347612e39a3 34
niv17 0:5347612e39a3 35 // FORWARD FOURIER TRANSFORM
niv17 0:5347612e39a3 36 // Input - input data
niv17 0:5347612e39a3 37 // Output - transform result
niv17 0:5347612e39a3 38 // N - length of both input data and result
niv17 0:5347612e39a3 39 static bool Forward(const Complex *const Input, Complex *const Output, const unsigned int N);
niv17 0:5347612e39a3 40
niv17 0:5347612e39a3 41 // FORWARD FOURIER TRANSFORM, INPLACE VERSION
niv17 0:5347612e39a3 42 // Data - both input data and output
niv17 0:5347612e39a3 43 // N - length of input data
niv17 0:5347612e39a3 44 static bool Forward(Complex *const Data, const unsigned int N);
niv17 0:5347612e39a3 45
niv17 0:5347612e39a3 46 // INVERSE FOURIER TRANSFORM
niv17 0:5347612e39a3 47 // Input - input data
niv17 0:5347612e39a3 48 // Output - transform result
niv17 0:5347612e39a3 49 // N - length of both input data and result
niv17 0:5347612e39a3 50 // Scale - if to scale result
niv17 0:5347612e39a3 51 static bool Inverse(const Complex *const Input, Complex *const Output, const unsigned int N, const bool Scale = true);
niv17 0:5347612e39a3 52
niv17 0:5347612e39a3 53 // INVERSE FOURIER TRANSFORM, INPLACE VERSION
niv17 0:5347612e39a3 54 // Data - both input data and output
niv17 0:5347612e39a3 55 // N - length of both input data and result
niv17 0:5347612e39a3 56 // Scale - if to scale result
niv17 0:5347612e39a3 57 static bool Inverse(Complex *const Data, const unsigned int N, const bool Scale = true);
niv17 0:5347612e39a3 58
niv17 0:5347612e39a3 59 protected:
niv17 0:5347612e39a3 60 // Rearrange function and its inplace version
niv17 0:5347612e39a3 61 static void Rearrange(const Complex *const Input, Complex *const Output, const unsigned int N);
niv17 0:5347612e39a3 62
niv17 0:5347612e39a3 63 static void Rearrange(Complex *Data, const unsigned int N);
niv17 0:5347612e39a3 64
niv17 0:5347612e39a3 65
niv17 0:5347612e39a3 66
niv17 0:5347612e39a3 67 // FFT implementation
niv17 0:5347612e39a3 68 static void Perform(Complex *const Data, const unsigned int N, const bool Inverse = false);
niv17 0:5347612e39a3 69
niv17 0:5347612e39a3 70 // Scaling of inverse FFT result
niv17 0:5347612e39a3 71 static void Scale(Complex *const Data, const unsigned int N);
niv17 0:5347612e39a3 72 };
niv17 0:5347612e39a3 73
niv17 0:5347612e39a3 74 #endif