4 #include "FFT/FFTReal.h"
22 bool begin(
int len)
override {
25 if (p_x==
nullptr) p_x =
new float[len];
26 if (p_f==
nullptr) p_f =
new float[len];
27 assert(p_fft_object!=
nullptr);
30 return p_fft_object!=
nullptr && p_x!=
nullptr && p_f!=
nullptr;
33 if (p_fft_object!=
nullptr)
delete p_fft_object;
34 if (p_x!=
nullptr)
delete[] p_x;
35 if (p_f!=
nullptr)
delete[] p_f;
36 p_fft_object =
nullptr;
45 memset(p_f,0,len*
sizeof(
float));
46 p_fft_object->do_fft(p_f, p_x);
52 p_fft_object->do_ifft(p_f, p_x);
63 return (p_x[idx] * p_x[idx] + p_f[idx] * p_f[idx]);
66 bool isValid()
override{
return p_fft_object!=
nullptr; }
69 float getValue(
int idx)
override {
return p_x[idx];}
71 bool setBin(
int pos,
float real,
float img)
override {
72 if (pos>=len)
return false;
78 if (pos>=len)
return false;
107 return driverEx()->p_x;
112 return driverEx()->p_f;