Aliasing
🎯 Learning Objectives:
In this topic, we will understanding aliasing in audio signals. We start the discussion by looking at how aliasing could occur in video signals and how the aliasing pattern that we visually see can be applied to understand the concept of aliasing in audio signals. We force aliasing to occur in the digital domain by using the Nyquist programming language, draw a pattern, and derive a formula for predicting the aliased frequencies. We illustrate the process of sampling and see how a low sampling rate coupled with high frequencies can cause aliasing. We will take the discussion towards real world observations of aliasing in square waves, and how to counter them manually using oversampling and downsampling.
Here is an effect that we have all observed before while watching a movie in which the wheels of a car are spinning or the blades of a propeller are rotating and as the rotation increases we can sometimes observe the optical illusion of the rotating object standing still and jittering around and sometimes even reverse its direction. This effect is commonly referred to as the wagon wheel effect and the phenomenon is called temporal aliasing.
Before we delve into illustrating how a low sampling rate coupled with high frequencies can cause aliasing we will first listen to what aliasing sounds like. This is generally harder than it seems because modern signal paths are really good at eliminating aliasing when an analog signal passes through an analog to digital converter. It filters out all frequencies above the Nyquist rate and when a sample digital signal passes through a digital to analog converter essentially the same process of filtering occurs we cannot bypass these steps to force aliasing because they are baked into the analog circuitry. Our only hope is to introduce high frequencies within the signal in the digital domain even then modern commercial applications and plugins like pitch shifters and compressors and ring modulators, which actually create higher frequencies within our digital audio signals are aware that aliasing is a possibility when the signal is processed and they account for it by internally over sampling the signal. Sometimes this mechanism is transparent and you would not even know that it is happening and sometimes they give us the option to choose the degree of over sampling.
The aim of this topic is to give enough clarity and understanding of aliasing irrespective of what you plan to do and hopefully you can continue the investigation further depending on your needs and use cases. We are using audacity with a project sampling rate of . If we can recollect from the topic on sampling that we cannot generate a sinusoidal tone higher than the Nyquist frequency of . In this topic we will bypass this rule and generate higher frequencies. Let us watch the video below.
As we hear in the video that the sine tone does not sound like . But we also saw that if we zoom in,the waveform looks decently well sampled. If we do a spectrogram analysis of the tone, we can see that it is a very precise representation. Our original tone has been transformed into a tone, when our sampling rate was set to . If we repeat the same experiment with an input of , this time we get a higher frequency representation of . In the Figure below are the spectrum of these tones.

Figure 1. Sine wave of single frequency in time domain
Here in the Figure below, we can almost see a pattern here.

Figure 1. Sine wave of single frequency in time domain
Let us put a picture to this pattern. Let us generate a sinusoidal sweep from all the way up to the sampling rate of . Let see the video below.
Here are the aliasing pattern in the Figure below. We can see all the frequencies above the Nyquist frequency of are folded back onto the original spectrum. It does not just stop there, though the folding happens constantly at the sampling boundaries, as the input signal frequency increases.

Figure 1. Sine wave of single frequency in time domain
In the Figure below is what a sine sweep would look like when sampled at . The sample signal is folded three times over.

Figure 1. Sine wave of single frequency in time domain
Let us summaries this phenomenon by plotting a graph of the frequency over time for the original input signal and the raw sampled output signal. Let us draw a line cutting through a single frequency we want to observe (see Figure below). Let us say . We can see that is a recurring frequency within the sampled signal but only appears once in the original input signal. Input frequencies that are inferred as are , , and and so on, it keeps going on. We can find out all the possible aliases of a given frequency by the formula below, where is the sampling frequency is our given frequency and n is any whole number above zero.
A profound implication that can be stated from all this is that there are an infinite number of aliases for every sampled frequency. Even more profound is the fact that any sine wave is indistinguishable from an infinite number of other sine waves after sampling and this is where the problem lies.

Figure 1. Sine wave of single frequency in time domain
Let us say that now we regret not having had a filter to cut off frequencies above the Nyquist and we want to get rid of the folding effect that's been plaguing our output sample signal. How do we do this. We cannot! Once an alias frequency enters the sample signal it is indistinguishable from all the other valid frequencies. There is no telling them apart.
To illustrate the sampling process visit the page Aliasing Simulator. You can interactively change sampling frequencies, signal frequency and other parameters to see how the aliasing occurs in the signals.
That sounds pretty awful. It is absolutely in-harmonic. Why does this happen?
Any waveform can be produced by adding together a number of sine waves. A square wave is produced by adding a fundamental sine tone along with all its odd harmonic partials. All we need to know now is that the fundamental frequency is our starting base frequency and a harmonic partial is an integer multiple of the fundamental frequency, , for a square waves.

Figure 1. Sine wave of single frequency in time domain
For a square wave, we select only the odd numbered harmonic partials and these partials are scaled down by a factor of their index. If we add enough partials together we get a close approximation of the square wave but we will never be able to achieve the perfect square wave that is because we would need an infinite number of partials and an infinite bandwidth to represent them. However, this is the digital domain after all and we can essentially do anything we want.

Figure 1. Sine wave of single frequency in time domain
Interactive Simulation: An interactive example is given in Square Wave Simulator where you can add partials and see how the square wave get near to perfect.
Audio
Some software, such as, audacity, probably implements wave table synthesis to produce a square wave. In this case the data points for a perfect square wave are already stored in a tabular form and this table is scanned at the rate of the desired frequency. This will give us a near perfect square wave but along with it comes a ton of high frequency partials that will be aliased back into the original signal because their frequencies are above the Nyquist.
The worst part about aliasing is that the partials lose their harmonic relationship with the fundamental as soon as they are folded back into the signal and this results in a sound that is in-harmonic and atonal. Aliasing is also irreversible and near impossible to get rid of at this point of time.
So what is the solution the solution?
Should ideally be offered by the digital synthesizer. During the design of these synthesizers or effect units, aliasing should be accounted for and avoided in the first place. One way to achieve this is by limiting our frequency content when generating our square wave and software such as, audacity, probably, used additive synthesis to choose only partials below the Nyquist when generating the square wave. But what do we do when our synthesizer offers no defense against aliasing distortion. There are other ways to overcome most of the aliasing distortion. We can use over sampling and down sampling.
Let do an experiment by generating a regular square wave at 192 kHz that is a little more than four times as high as 44.1 kHz and that we know it contains aliasing distortion and click. Let us first listen to it.
Audio
Well that is not bad. It still contains a bit of in-harmonic roughness that is caused due to aliasing but it is nowhere near bad enough when compared to the signal generated at the rate to 44.1 kHz. If we look at the Figure we can understand why this is the case. All we did by sampling higher is we moved the bar beyond which folding occurs from 22 kHz all the way up to 96 kHz. All of these frequency components above 22 kHz are in the signal but they are above the audible limit, so we cannot hear them at all. The only ones we can hear are the frequency components that were folded back at 96 kHz and traverse back all the way down to the audible range. However, the intensity of all these alias components that are audible are considerably low and that is the reason we hear less aliasing distortion at this point.

Figure 1. Sine wave of single frequency in time domain
The signal can be resampled down to an appropriate sample rate. Let us resample by setting to rate. Audibly we did not change any aspect of the signal when we re-sampled down. Let us listen the resampled square wave again.
Audio
We used a rough factor of four when over sampling from to . Digital software are known to over-sample from a factor of to even or .
🧪 Interactive Demo
Fourier / Harmonic Synthesis
Animated harmonic addition — add harmonics to build the waveform and listen.
📝 Key Takeaways
- Add key takeaway
🧠 Quick Quiz
1️⃣ What is the main cause of aliasing in digital audio?
2️⃣ What phenomenon is visually observed when a rotating wheel appears to move backwards in film?
3️⃣ If a sine wave of 7 kHz is sampled at 8 kHz, what is the aliased frequency heard?
4️⃣ Using the aliasing formula f_a ∈ {n*f_s ± f}, if the sampling frequency f_s = 8 kHz and input f = 6 kHz, what is the first positive alias frequency?
5️⃣ A square wave contains a fundamental frequency of 1 kHz. Which harmonics will primarily cause aliasing if sampled at 4 kHz?
6️⃣ A digital synthesizer samples a 16 kHz sine sweep at 8 kHz. How many times will the waveform fold over?
7️⃣ Oversampling is used in digital audio to:
8️⃣ Numerical: A signal of 15 kHz is sampled at 8 kHz. Using the aliasing formula f_a ∈ {n*f_s ± f}, what is the first alias frequency observed?
9️⃣ Numerical: If a square wave contains odd harmonics 1 kHz, 3 kHz, 5 kHz, 7 kHz and we sample at 4 kHz, which harmonics will be aliased within the audible range?
1️⃣0️⃣ True/False: Once aliasing occurs in a digital audio signal, it is reversible and can be removed completely.