# Interpolation by factor of 2

I want to up-sample my input signal by a factor of $2$. I saw zero padding followed by low pass filter method being used in few cases. But still I need some help in this.

• Say I have $10$ input samples and my interpolating factor is $2$, then if I am doing interpolation using above method, will I get $20$ samples at the output?
• Also how to increase the pass-band gain of the low pass filter to $6.02\textrm{ dB}$?
• Please clarify what you mean by interpolation by zero padding. Zero padding itself does not interpolate your signal. It must be followed by a low pass filter, in which the entire art of interpolation rests. – Phonon Apr 23 '13 at 5:49
• @Phonon do you have any starting point (links or reference) for this art of design low pass filter for interpolation only. – Stephane Rolland Apr 23 '13 at 10:39
• For midpoint interpolation, see also Hamming, Digital Filters pp. 151-152 (straight up, no 0 insertion / lowpass). Try [-1 9 9 -1] / 16. – denis May 29 '13 at 13:48

## 3 Answers

When you upsample by a factor of two by inserting a zero between each sample you create an alias of your signal centered at the new Nyquist frequency (half the new sample rate). You get rid of the alias by low-pass filtering.

The specifications of the filter that you need depend on your signal. Say that your signal has one-sided bandwidth $B$ (by one-sided I mean that we are only talking about the positive frequencies, not the negative ones). $B$ must have been less than the Nyquist frequency of the old sample rate, $f_{sOld}$, to avoid aliasing. Once you upsample the alias appears. Hopefully these pictures will help to gain an intuitive grasp of how to characterize the required low-pass filter. The passband must be flat from 0 Hz to $B$ Hz, and it must cutoff at $\frac{f_{sNew}}{2} - B = f_{sOld} - B$. The amount of attenuation that is required in the cutoff region depends on your application. Usually 50 dB is more than sufficient.

• great picture, very helpful. I'd be carefully for blanket statements like "50 dB is usually sufficient". For most HIFI audio application this wouldn't be true. – Hilmar Apr 23 '13 at 15:44
• It's a nice picture, but I'm pretty sure it's misleading. The image of the 0 to $B$ will also appear from $f_{sOld}-B$ to $f_{sOld}$ in the first (pre-zero-insertion) picture, will it not? All that happens by inserting alternate zeros is that the effective sampling rate is increased... the representation in the frequency domain doesn't change (though there may be a scale factor). – Peter K. Apr 23 '13 at 17:15
• @PeterK. Yes and no. In a sense it is "there", but it is above the Nyquist frequency so it is indistinguishable from the original signal. Please see dsp.stackexchange.com/questions/1775/… – Jim Clay Apr 23 '13 at 17:32
• @Hilmar Thus the word "usually". – Jim Clay Apr 23 '13 at 17:36
• @JimClay The picture in the linked-to question is much clearer than the picture here (with the images below $f_{sOld}$ dotted / shaded rather than non-existent as they are(n't) here). The pictures here say there is NOTHING below $f_{sOld}$ or below $f_{sNew}$ which, as I said, is misleading (though I can see why you quibble). – Peter K. Apr 23 '13 at 17:55

Looks like a bit of confusion here. Zero-padding (before an FFT) will provide interpolation in the frequency domain. Interpolation in the time domain is done (typically) by inserting zeros between samples and then applying a suitable low pass filter.

"Suitable" here depends highly on the requirements of your application, there is no "one size fits all" filter. Things to consider are passband ripple, phase distortion, residual aliasing, latency, stop band attenuation, causality, transient behavior, etc. Stanford's Julius Smith teaches a good course on the topic https://ccrma.stanford.edu/~jos/Interpolation/

If you must zero-pad to do a 2X interpolation, one solution is to zero-pad around Fs/2 in the frequency domain, and then IFFT this 2X longer vector to produce the 2X longer time domain data.

Also, additional zero-padding in the time domain before the first FFT might help reduce circular convolution effects (assuming that that is less offensive than tapering to the padding level at the data edges).

• Interpolating that way in the frequency domain is equivalent to using a "perfect" square filter that introduces ringing due to the Gibbs effect. – Jim Clay Apr 23 '13 at 17:39
• This is true if there is any spectral energy around the original Fs/2, which would cause problems (loss,ringing) with any interpolation filter. If there is no data around a filter's transition, then multiplying zero by either a rectangular edge or something like a raised-cosine taper produces nearly the same result, zero. – hotpaw2 Apr 23 '13 at 17:50