What's the correct way. Should I zero-pad a signal before or after applying a windowing function?
3 Answers
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.
-
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 ClayJan 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
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.
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.
signal -> zero pad -> FFT -> Window
but just my opinion. $\endgroup$