Hi, here are some lines of code which do not work. I generate a sinus, try to make a forward then inverse fft transform. The output signal is just noise.
void MainContentComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
jassert( bufferToFill.buffer->getNumSamples() == 512 );
int numSamples = bufferToFill.buffer->getNumSamples();
float lTime = 0.f;
for (int channel = 0; channel < 2; ++channel)
{
lTime = mTime;
FFT lFFT(9, false);
float * fftData = new float[numSamples * 2];
// fill the fft data with a sinusoidal signal.
for(int i = 0; i < numSamples * 2; i++)
{
if(i < numSamples)
{
lTime += 0.09;
fftData[i] = 0.1f * cos(lTime);
}
else{
fftData[i] = 0;
}
}
lFFT.performRealOnlyForwardTransform(fftData);
lFFT.performRealOnlyInverseTransform(fftData);
bufferToFill.buffer->copyFrom(channel, 0, fftData, numSamples);
}
mTime = lTime;
}
It's not about "real data" vs. "fake data" but the real part of complex numbers. To restore the spatial information from the frequency domain you need the frequencies AND the phase information, which is in the real part.