# Basic method for 2x oversampling?

I would like to know if the following method of 2x oversampling is correct:

Interpolate:

• Take an original signal sampled at 44100Hz as input
• Upsample by adding a zero after each original sample to get a signal twice as long
• Filter the new signal using a low pass filter (cutoff of 44100Hz based on new sample rate of 88200Hz)

Use new signal:

• Do some additional filtering of the the new signal at 88200Hz

Decimate:

• Take the final signal at 88200Hz as input
• Filter using a low pass filter (cutoff of 44100Hz based on sample rate of 88200Hz)
• Downsample by removing every other (odd) sample
• Now have a signal that is 44100Hz again

What I would like to check is if the method is correct and my cut off frequencies for my low pass filters are right.

Interpolation (sampling frequency 44.1 kHz ➔ 88.2 kHz)

Your original 44.1 kHz sampled signal has frequencies up to 22.05 kHz, so you should lowpass filter at 22.05 kHz after dilution with zeros. Your filter should have a gain of 2. Otherwise the signal amplitude drops to half because you set half of the samples to zero. Like Jim Clay says, you can combine these things; there will be plenty of opportunity for optimization.

Downsampling (sampling frequency 88.2 kHz ➔ 44.1 kHz)

If your 88.2 kHz sampled signal is the one you lowpass filtered at 22.05 kHz, you can simply decimate by throwing away every second sample. Otherwise, first lowpass filter at 22.05 kHz to prevent aliasing, and then decimate. If you combine lowpass filtering and decimation, you can optimize again.

• Brilliant, thanks, I've re-checked my maths and yes it looks like my low pass filters should be 22050Hz. Thanks also for mentioning I need to adjust the gain of my low pass interpolator :-) Oct 21 '15 at 11:01
• @OlliNiemitalo Good catch on the 22.05 kHz. I'm a little embarrassed that I overlooked that. Oct 21 '15 at 16:05

Yes, your method is correct, and will work just fine.

You can reduce the computational load by combining the upsampling (insertion of zeros) and low-pass filter into a single interpolating filter, and combining the low-pass filter and removal of samples into a single decimating filter, but that is not necessary to get correct results.

You have the right idea about Interpolation/Decimation and the steps involved. Two points:

Interpolation:

When you insert zeros between samples, the spectrum is now the new sampling frequency wide (88.2kHz in your case) with copies of the original spectrum showing up at multiples of the original frequency (44.1kHz in your case). When you lowpass filter, your cutoff should be [original sampling frequency - 1/2 bandwidth of original signal] (44.1kHz - 1/2*BW) since you want to eliminate the new copy. The copy centered at 44.1kHz will have a bandwidth that is the same as the original signal so you need to filter lower than the edge of your copy's bandwidth.

Decimation:

When you decimate, the higher frequencies of the spectrum fold in on top of your new sampling frequency spectrum. If your lowpass filter has a (3dB) cutoff of 44.1kHz, you'll end up having some spectral content beyond 44.1kHz (unless you were to use an ideal rectangle/brickwall filter which is not practical). In practice you should design the filter to cutoff enough of the spectral content beyond 44.1kHz to satisfy your requirements. This would involve setting the cutoff a little below 44.1kHz and starting the stopband at 44.1kHz. (MATLAB's filter functions let you choose both 3dB cutoff and stopband frequencies.) Make sure to choose enough attenuation in the stopband to satisfy your requirements.

• By curiosity, would duplicating the values be better/worse than inserting zeroes ? Oct 21 '15 at 6:50
• @YvesDaoust: Duplicating values is the same as inserting zeros and then convolving with a [1, 1] kernel. That is a very gently sloping filter that attenuates by 3 dB the frequency at half the original sampling frequency. Not a good idea. Oct 21 '15 at 16:51
• @jeremypatterson, I'm seeing conflicting advice from various sources on whether the stop band should be Nyquist or as you say 1.5 * Nyquist. Which literature did you use for your information? I think I need to spend some time fully digesting some good material. Oct 22 '15 at 8:35
• From doing this on actual applications, it helps me to visualize the effects of each filter by plotting the spectrum before and after filtering the signal. If the filter you chose removes enough of the spectral content, you are good to go. One point of confusion can be what is meant by "cutoff frequency". If this is only the -3dB point, your copy will only be attenuated by 3dB. If "cutoff" means stopband start (-40dB), you may be . As for literature: I usually make a MATLAB example and try different designs. "Understanding DSP" by Richard Lyons has a pretty good chapter about this. Oct 27 '15 at 15:34

When downsampling, the cut-off of the low-pass filter, needed to prevent aliasing, should be at or (more realistically) below half the new target sample rate.

But if you start with a signal that is already band-limited below 22kHz, and only perform noiseless linear filtering on it, this additional anti-alias filtering might be redundant (for a target rate of 44.1k).