7
$\begingroup$

What's the correct way. Should I zero-pad a signal before or after applying a windowing function?

$\endgroup$
5
  • $\begingroup$ I'd go with before the signal, at the rate in which you are computing the FFT, so signal -> zero pad -> FFT -> Window but just my opinion. $\endgroup$
    – Phorce
    Jan 12, 2014 at 14:14
  • $\begingroup$ Is there an argumentation why to go this way? $\endgroup$
    – mhawker
    Jan 12, 2014 at 14:16
  • 1
    $\begingroup$ Post to dsp.se before or after comp.dsp? $\endgroup$
    – John
    Jan 12, 2014 at 14:37
  • $\begingroup$ @mhawker - I don't believe it really matters. Ok, for example, why do you zero-pad? Well, usually, to produce a longer FFT resulting vector. I don't understand why you would do this after applying the window function, because in essence the analysis has already been done. dsp.stackexchange.com/questions/741/… $\endgroup$
    – Phorce
    Jan 12, 2014 at 14:39
  • $\begingroup$ Why would one want to do this? $\endgroup$
    – user7358
    Jan 12, 2014 at 17:54

3 Answers 3

10
$\begingroup$

If done correctly, the order should not matter. You apply windowing to remove the jumps at the end of the signal segment by fading the values there to zero. Zero-padding then continues with zeros. Irregardless if padded or not, the windowing should only be applied to the original signal segment.

The wrong way would be to zero-padding and then apply windowing to the new longer signal over its full length, i.e., without regard to the position of the jumps. This would not remove the jumps and thus keep the background in the spectrum non-related to the frequency content of the signal but the segmentation method.

$\endgroup$
5
  • 1
    $\begingroup$ "If done correctly, the order should not matter." what, Lutz?? are you implying that multiplication is a commutative operation? $\endgroup$ Jan 12, 2014 at 18:46
  • $\begingroup$ No, only as explained that the windowing might be applied to the wrong segment, with disastrous results. $\endgroup$ Jan 13, 2014 at 0:14
  • $\begingroup$ i was being sorta facetious, L. order should not matter because multiplication is commutative. just make sure the overall window, $w[n]$, is the same between the two cases for all samples. $w[n]=0$ for those samples corresponding to the zero padding. this question was just asked at the USENET group comp.dsp. i think maybe by the same person. $\endgroup$ Jan 13, 2014 at 4:19
  • $\begingroup$ @robertbristow-johnson Isn't the point of the question the fact that the window in the two cases is different? $\endgroup$
    – Jim Clay
    Jan 13, 2014 at 14:50
  • $\begingroup$ well, the question is not clear about that. only about whether to "zero-pad a signal before or after applying a windowing function". i am assuming the operations are adjacent to each other in the signal chain and there is nothing (like an FFT) going on in between. zero-padding is equivalent to multiplying the samples that were there to begin with by zero. those zeros can be combined with the non-zero samples of the window to be a bigger window of sorts. of course, if the window in the two cases are different, the results are different. $\endgroup$ Jan 13, 2014 at 16:10
5
$\begingroup$

I would window and then zero-pad.

The purpose of the window is to smooth out the boundary transitions. When you zero-pad you are introducing a very abrubt transition at the zero-pad point which, if you want the window to be effective, is where the smoothed out transition should happen.

$\endgroup$
4
$\begingroup$

You must window your data, before zero-padding. The point of the windowing process is to smooth out the end-points of your data prior to taking the FFT, so that we reduce spectral leakage.

If you zero-pad and then window, you are making the implicit statement that all the zeros you added are part of your data, which is incorrect.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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