Oversampling is all about processing signals at a higher sample rate than the original material. This is an important technique that can be used to remove aliasing from non-linear processes such as modulation or distortion.


Modulation and Aliasing

Modulation is essentially a multiplication – which, when applied to a signal in the time domain, results in a convolution in the frequency domain. On a frequency chart, you can see that reflections of the original spectra are created.

Figure 1 - Modulation products

As it happens, the very act of sampling digital audio is to modulate an input signal by a sampling signal. This reflects the original signal spectrum at multiples of the sampling frequency (Fs). These reflections are called aliases. In the diagram below, the original spectrum is shown in magenta, and the first two sets of aliases are shown in grey-blue.

Figure 2 - Sampling products

It is very important to make sure that the original spectrum is limited to less than half of the sampling rate. Ideally this would be done with a rectangular low pass filter. Without an appropriate filter, the original spectrum could extend past Fs/2, as shown in the following diagram.

Figure 3 - Overlapping sampling products

Here you can see that the aliases overlap the original spectrum. As the interfering alias spectrum is actually mirrored (back-to-front), the resulting alias distortion is in-harmonically (or unmusically) related to the original. To most people this sounds really bad. What’s worse is that we can’t filter it out without also filtering out the top bit of the signal we want to keep.


Oversampling

In a properly designed digital audio system, our A/D and D/A converters have nice low pass filters built into them to prevent aliasing distortion. However, when we're building our own digital audio processor we sometimes want to perform modulations or build oscillators that could potentially generate frequency content above Fs/2. When we do this, we need to find a way to prevent aliasing distortion – and that’s where oversampling comes in.

With oversampling, what we do is perform our non-linear processing operations at a higher sample rate so that the aliases are pushed further along the frequency axis. If we oversample by a factor of two, then we are going to be effectively processing at 2Fs. The following diagram shows how our problem aliases are now safely away from our original signal.

Figure 4 - 2x oversampling

Thus we can filter things with a sharp filter at Fs/2 and everything will be OK (at least in this case). However, oversampling by 2x will only help us up to a certain point. If the original spectrum extends past Fs, then we’ll get aliasing distortion again – so we’d need to oversample at an even higher rate.


2x Downsampling

Also known as decimating, the process of downsampling requires us to low pass filter the processed signal to Fs/2 with a nice, sharp filter. Then we just throw away the samples we don’t want. In the case of 2x downsampling, this means we throw away 1 out of every 2 samples.

Figure 5 - Downsampler


2x Upsampling

If we’re going to operate at a higher sample rate, where do we get the extra samples from? It might be tempting to just try a linear interpolation to estimate the in-between samples. The problem with this is that this process introduces its own aliases. Better results can be obtained by polynomial interpolators, but these become computationally expensive when trying to obtain sufficient quality.

Funnily enough, the most practical approach is to use the same filter as used for downsampling. In the case of a 2x filter, you feed it two inputs. The first input is your original signal, while the second is simply set to zero. This is called “zero stuffing” and it results in aliases being produced just like in figure 2. What’s really neat is that the filter preserves the original spectrum and removes the aliases. What we end up with is the original waveform, but at the increased sampling rate. Magic!

Figure 6

Figure 6 - Upsampler


 

Oversampling At Higher Factors

We can oversample at higher multiples of two by cascading filters and appropriately zero stuffing or discarding samples at each stage.

Figure 7

Figure 7 - Oversampling cascade


References

The following web site gives a good explanation of sampling, aliasing, and other things you should be aware of when working with digital audio: http://www.earlevel.com/main/category/digital-audio/

The dspGuru site has a great FAQ on Multirate DSP: http://www.dspguru.com/dsp/faqs/multirate

If you’re more mathematically inclined, visit Laurent de Soras’ site at http://ldesoras.free.fr/prod.html and read his excellent paper entitled “The Quest For The Perfect Resampler”.