# Zero padding issue - cut the buffer

I have some issue with zero padding. It's probably because I don't understand it enough.

I have buffer size set to 400. And I use radix-2 fft. So I take the input signal 400 samples, and add to them 112 zeros. So I have acceptable 512 buffer size for radix-2. And then I take the output of fft (freq spectrum) and send it to inverse radix fft. And that's what I get: it's my buffer window of size 512. So the end of buffer is cut. I suppose it's those 112 zeros. So it looks quite logical: actually I sent to my forward fft buffer size that has signal only for first 400 samples, and the rest are zeros. So after inverse I get what I had on input. I can understand that. But how to deal with that?

OK, I think I could just use from inverse fft output just those first 400 samples and it probably would work. But I wonder if it's proper way? Maybe there is some smarter solution, some filtering or what?

The result you experience is reasonable. The IDFT performs exactly the inverse operation of the forward DFT. Hence, for every signal $x[n], n=0...L$ you have the identity:

$$x[n] = \text{IDFT}\{\text{DFT}\{x[n]\}\}$$

This property is valid for DFT and hence also for FFT (as it is a special implementation of DFT).

So, if you insert a zero-padded sequence $x[n]$ into the FFT and immediately perform IFFT you obtain the zeropadded sequence as the output.

The question is: Why would you want to do that? If you think of performing filtering in the frequency domain, dont do it.

• And of course I know the result is reasonable, I said that in my question, but instead word "reasonable" I used "logical" (due to my faulty English). But the question was how to avoid those "reasonable" results. I mentioned in question that I know I can use only first 400 samples from buffer and it would work. But is there any smarter methods to do that? Jul 10, 2018 at 4:58
• And no I am not going to perform filtering by zeroing freq bins. I've already done that and I know the results :) Now I am just testing FFT, and try to understand that as best as I can. For example I wonder why Radix-2 is so popular. It allows you to perform FFT only for 2L buffer sizes. But there is great FFT called Mixed Radix. It allows you to perform FFT on almost each buffer sizes. So when there is so popular sample rating 44100, why not just use mixed radix? Jul 10, 2018 at 4:59
• So your question is actually: Why is the radix2-fft so popular, whereas the mxed-radix are more rarely found? Jul 10, 2018 at 5:36
• It’s only one of many questions :) Jul 10, 2018 at 5:37
• But here exactly I am asking how to avoid that issue which I have with radix-2 when I make zero padding Jul 10, 2018 at 5:38