Can you help me with this FFT filter freq response plot?

Hi good boys,

I’m discovering FFT and how to plot freq response (following this my old post and suggestion by @kerfuffle).

So I tried using basic tools of JUCE, which works pretty straightforward (searching also code online):

// Create impulse
zeromem(mImpulse, sizeof(mImpulse));
mImpulse[0] = 1;
zeromem(mFilteredImpulse, sizeof(mFilteredImpulse));

// Filter impulse
for (auto i = 0; i < fftSize; ++i)
{
	mFilteredImpulse[i] = filterIIR.processSample(mImpulse[i]);
}

// Perform fft
mFFT.performFrequencyOnlyForwardTransform(mFilteredImpulse);

Now, I’d like to use different library (in this case, pffft).
So I tried to write the same code:

    // Create impulse
zeromem(mImpulse, sizeof(mImpulse));
mImpulse[0] = 1;
zeromem(mFilteredImpulseTemp, sizeof(mFilteredImpulseTemp));

// Initialize the PFFFT library
PFFFT_Setup *fft_setup = pffft_new_setup(fftSize * 2, PFFFT_REAL);

// Perform the FFT of the impulse
pffft_transform_ordered(fft_setup, mImpulse, mFilteredImpulseTemp, nullptr, PFFFT_FORWARD);

// Filter impulse
for (auto i = 0; i < fftSize; ++i)
{
	mFilteredImpulseTemp[i] = filterIIR.processSample(mImpulse[i]);
}

// Perform the inverse FFT to get the filter's response
pffft_transform_ordered(fft_setup, mFilteredImpulseTemp, mFilteredImpulse, nullptr, PFFFT_BACKWARD);

// Normalize the filter response
for (int i = 0; i < fftSize * 2; ++i)
{
	mFilteredImpulse[i] /= fftSize * 2;
}

But, with the same settings:

enum
{
	fftOrder = 14,
	fftSize = 1 << fftOrder
};
float mImpulse[fftSize] = {0.0f};
float mFilteredImpulse[fftSize * 2] = {0.0f};
float mFilteredImpulseTemp[fftSize * 2] = {0.0f};	

can’t match the values, and I don’t understand where am I wrong.

With your experience, can you help me to understand where the mismatch come from? Probably a factor scaling when I get back the values?

I could also use fftw if you already have experience with it, or some others libraries (the purpose is to use a common library, which can be used in different platforms in future, if needed).

Thanks to anyone can give to me the right direction, and some tips :slight_smile: