I made a C++ FFT filtering project, filters are stored in a vector of pointers to classes with a virtual function.

But the filters aren’t being applied to the FFT. Is like the output was the inverse FFT of the unfiltered FFT, but it is clearly in fact the inverse FFT of the filtered one. I’m sure is a stupid error, but I’m unable to find it. Using SDL audio subsystem for input and output.

audio_callbacks.cpp:

```
void SDLCALL AudioInputCallback(void *userdata, Uint8 *stream, int len) {
//memcpy_s(_InputBuffer.WaveBuffer.real, BUFFER_SIZE, stream, len);
CopyBuffer(_InputBuffer.WaveBuffer.real, (sample*)stream, BLOCK_SIZE); // Copy float wave buffer from sound card to the real part of the input wave buffer iwave.r = istream
FillBuffer(_InputBuffer.WaveBuffer.imag, 0, BLOCK_SIZE); // Empty the imaginary part of the input wave buffer iwave.i .= 0
FFT_fwd(BLOCK_SIZE, _InputBuffer.WaveBuffer, _InputBuffer.FFTBuffer); // FFT of input wave buffer, to input FFT buffer ifft = fft(iwave)
FilterFFT(_InputBuffer.FFTBuffer, _OutputBuffer.FFTBuffer, BLOCK_SIZE); // Input FFT buffer is unfiltered, Output FFT buffer is filtered offt = filter(ifft)
// testing stuff:
//FilterFFT(_InputBuffer.FFTBuffer, _InputBuffer.FFTBuffer, BLOCK_SIZE);
//FillBuffer(_OutputBuffer.FFTBuffer.imag, 0, BLOCK_SIZE);
//FillBuffer(_OutputBuffer.FFTBuffer.real, 0, BLOCK_SIZE);
FFT_rev(BLOCK_SIZE, _OutputBuffer.FFTBuffer, _OutputBuffer.WaveBuffer); // Reverse FFT of output FFT buffer, to output wave buffer owave = ifft(offt)
SwapInputBuffers();
SwapOutputBuffers();
}
void SDLCALL AudioOutputCallback(void *userdata, Uint8 *stream, int len) {
//memcpy_s(stream, len, OutputBuffer._My_val.WaveBuffer, BUFFER_SIZE);
//memcpy_s(stream, len, _OutputBuffer.WaveBuffer, BUFFER_SIZE);
for (size_t i = 0; i < BLOCK_SIZE; i++)
((sample*)stream)[i] = OutputBuffer._My_val.WaveBuffer[i]; // Copy filtered output wave to soundcard stream = owave
}
```

CopyBuffer and FillBuffer is self explanatory. FFT_fwd is a external implementation of forward FFT. FFT_rev is inverse FFT.

FilterFFT is defined in an other file (filer.cpp), it takes a FFT and filters it according with the filters vector. SwapInputBuffers and SwapOutputBuffers are for double buffering the audio.

I link the whole project here: http://arf20.mooo.com/source/audiofft/audiofft/audiofft.rar

Thank you

Source: Windows Questions C++