I record a sample of 2000 data points, with a sampling rate of 40khz, so freq. resolution is 20hz. I multiplied the chunk of data with a Hanning window prior to doing the FFT.

I recorded a 1khz test tone, and the result of FFT showed a peak at 1khz, as it should. But the magnitudes at 980hz and 1020hz is also significantly higher than the rest, although not as high as the magnitude at 1khz (about 50%).

Is this really bad? Did I apply the Hanning window wrong or is this unavoidable? Will using finer frequency resolution help?

  • $\begingroup$ for any frequency component having frequency that is not exactly an integer times 20 Hz, there will be spectral leakage apparent. now 1 kHz is 50 times 20 Hz, so are you sure the frequency your 1 kHz tone was precise? $\endgroup$ – robert bristow-johnson Aug 13 '19 at 2:25
  • $\begingroup$ It's ok. If you used an FFT length of 2000 points, then only the bins at 980 Hz and 1020 Hz (and mirrors) should show up and all the rest be zero. For other FFT lengths you will see more nonzero components... $\endgroup$ – Fat32 Aug 13 '19 at 2:44
  • $\begingroup$ I played a 1khz tone from Youtube, so it might not be a precise signal I guess $\endgroup$ – user173729 Aug 13 '19 at 13:31

For the Hanning window, the zero crossings occur at a much wider bandwidth (trading for lower side-lobe height) compared to a rectangular window (sharper main-lobe width but higher side-lobe). You need to be careful with the requirements regarding the choice of window given the trade off between side-lobe height and main-lobe width.


If the data that is feed to an FFT is not exactly integer periodic in the FFT’s length, then there will always be windowing artifacts, either Sinc (or Dirichlet) shaped for the FFT’s default rectangular window, or the shape of the transform of any non-rectangular window (such as a Von Hann) applied. Sometimes this is called “leakage”.

Note that the main lobe of the transform of a von Hann window is actually wider than that of the default Sinc, so you will see higher magnitudes in the 2 bins on either side of the peak FFT magnitude result bin than if you didn’t apply a window function. (this is the trade-off for getting less noise in or from more distant FFT bins)

  • $\begingroup$ //"If the data that is feed to an FFT is not exactly integer periodic in the FFT’s length, then there will always be windowing artifacts"// - - - yes, and the true source of these artifacts is not in the FFT (or DFT) but is in the action of yanking $N$ samples from a stream of data. the DFT will always simply assume that the $N$ samples passed to it are one cycle of a periodic waveform having period of exactly $N$ samples. $\endgroup$ – robert bristow-johnson Aug 13 '19 at 20:21
  • $\begingroup$ An FFT is only a fast matrix multiplication for a specific basis transform, but humans are capable of making faulty assumptions about anything. No such assumptions are needed to do matrix multiplies. $\endgroup$ – hotpaw2 Aug 13 '19 at 20:48
  • $\begingroup$ i know hot, but the basis functions are all periodic with period $N$. whether you approve of my anthropomorphizing an algorithm or not, the FFT is an efficient DFT. the DFT and the Discrete Fourier Series are one-and-the-same. the DFT takes the $N$ samples passed to it as a complete definition of a periodic sequence having period length of $N$ and bijectively maps it to another periodic sequence also having period length of $N$. that is what the DFT does. $\endgroup$ – robert bristow-johnson Aug 13 '19 at 22:37
  • $\begingroup$ The DFT and the Discrete Fourier Series are not the same. The DFT can be used to compute a Discrete Fourier Series, as well as lots of other stuff that is not an infinite series at all, which is actually most common (given the Big Bang truncation of all signals in the known Universe, etc.) $\endgroup$ – hotpaw2 Aug 13 '19 at 23:06
  • $\begingroup$ no hot, they are precisely the same thing. except, in O&S, one uses $x[n]$ and $X[k]$ for notation and requires modulo arithmetic in the indices (which explicitly periodically extends the finite sequence) and the other uses $\tilde{x}[n]$ and $\tilde{X}[k]$ for notation and requires no modulo arithmetic in the indexing because the periodicity is understood: $\tilde{x}[n+N]=\tilde{x}[n]\ \forall n \in \mathbb{Z}$ and similarly for $\tilde{X}[k]$. but the math is identical for both. $\endgroup$ – robert bristow-johnson Aug 14 '19 at 0:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.