Audio FX
 
Loading...
Searching...
No Matches
fft.h
1#ifndef FFT_H
2#define FFT_H
3
4#include <vector>
5#include <fftw3.h>
6#include <complex>
7#include <thread>
8#include <mutex>
9using namespace std;
10typedef fftw_complex cpx;
11
12
18class FFT
19{
20private:
21 int n;
22 cpx *f;
23 static fftw_plan forward;
24 static fftw_plan backward;
25
26 // these vars are needed for multi-threading
27 static cpx *dummy;
28 static mutex m;
29
30public:
31 static bool planExists;
36 FFT(int n);
37
42
47 vector<complex<double>> fft(const vector<double> &v);
48
53 vector<double> ifft(const vector<complex<double>> &c);
54
59 static void preInit(int n);
60
64 static void destroyPlan();
65};
66
67#endif
static void destroyPlan()
Destroy plans once all FFT objects are out of scope. Needed for multi-threading.
static void preInit(int n)
Associated with constructor. Will only be called once per the scope of the FFT object instantiation....
~FFT()
Destroy FFT plans and buffers.
vector< complex< double > > fft(const vector< double > &v)
Apply FFT to vector v.
FFT(int n)
Allocate FFT plans and buffers , enabled for multi-threaded or serial use.
vector< double > ifft(const vector< complex< double > > &c)
Apply IFFT to complex vector c.