Hi,
I’m trying to create my own STFT class using FFTW to compute the FFT of an AudioBuffer. I spotted a weird behaviour with FFTW which seems to interact in a weird way with my AudioBuffer.
Here’s the code i’m using :
The STFT Class :
class STFT
{
public:
STFT(juce::AudioBuffer<float>* x, unsigned int windowSize): signal(x), windowLength(windowSize){};
~STFT();
void computeSTFT();
private:
juce::AudioBuffer<float>* signal;
int windowLength;
};
The compute_STFT function
void STFT::computeSTFT()
{
std::cout<<"in "<<signal->getNumSamples()<<"\n";
float* analysisFrame;
std::complex<float>* fftOut = new std::complex<float>[(int) (windowLength/2 + 1)];
fftwf_plan plan;
std::cout<<"mid "<<signal->getNumSamples()<<"\n";
plan = fftwf_plan_dft_r2c_1d(windowLength, analysisFrame, reinterpret_cast<fftwf_complex*>(fftOut), FFTW_MEASURE);
std::cout<<"mid2 "<<signal->getNumSamples()<<"\n";
fftwf_destroy_plan(plan);
delete fftOut;
std::cout<<"out "<<signal->getNumSamples()<<"\n";
}
This is what is printed in the terminal :
in 8865
mid 8865
mid2 0
out 0
So for some reason something happens to the AudioBuffer pointer when creating the fftw plan even though the AudioBuffer is not given as an argument to fftw’s plan creation function
Anyone know what is happening?