In one of my projects, I have to compute stfts with audio signals coming either from a microphone or a .wav file in a C++ based program.

However, I am observing different artifacts due to my stft chunk size and the overlap I am implementing. When I input a perfect 440Hz signal for example, I see the amplitude of my stft's variating with time following a sort of sinusoid. One would strictly expect a constant intensity with such a perfect signal. Any idea on what could cause this problem ? Computing the exact same stfts using python function numpy.fft.fft does not embed such artifacts.

In my C++ program, I am using either FFTW3 (intel processors) or NE10(arm processors) to compute the stfts, both giving the same artifacts. The signals are sampled at 16kHz, the fft chunk size is 512 samples with a hop size of 256 samples. I apply a hanning window to each chunks. I alread tried increasing the chunk size, the artifacts does not disappear.

My first guess would be that both C++ libraries do not normalize the outputs. But still, to have a constant intensity with my problem, the normalization factor should change depending on the current chunk, which does not make any sense as the normalization factor should be constant and equal in all chunks. Any idea on the cause of this problem ?

If my problem is not clear, I hope the next plots will help :

Here I plotted 500 of the STFTs I am computing with FFTW3 with a perfect 440hz signal as input. The peaks are correctly all at the same correct x values representing the frequency axis, but as you can observe, the dots representing the maximum value of the stfts are not constant, creating these sorts of harmonics (FFTW3 does not compute the symmetry part of the dft of a real signal)

Here is the exact same plot as before but this time with the stfts computed with numpy. As you can observe, the intensity is strictly constant as one would expect (two peaks due to the symmetry of the real stft.).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.