Digital Sound & Music: Concepts, Applications, & Science, Chapter 5, last updated 6/25/2013

45

5.3.4 Mathematics and Algorithms for Aliasing

Many of the concepts introduced in Sections 5.1 and 5.2 may become clearer if you experiment

with the mathematics, visualize or listen to the audio data in MATLAB, or write some of the

algorithms to see the results first-hand. We’ll try that in this section.

It's possible to predict the frequency of an aliased wave in cases where aliasing occurs.

The algorithm for this is given in Algorithm 5.1. There are four cases to consider. We’ll use a

sampling rate of 1000 Hz to illustrate the algorithm. At this sampling rate, the Nyquist

frequency is 500 Hz.

algorithm aliasing {

/*Input:

Frequency of a single-frequency sound wave to be sampled, f_act

Sampling rate, f_samp

Output:

Frequency of the digitized audio wave, f_obs*/

f_nf = ½ * f_samp //Nyquist frequency is ½ sampling rate

if (f_act = f_nf) //Case 1, no aliasing

f_obs = f_act

else if (f_nf f_act = f_samp) //Case 2

f_obs = f_samp – f_act;

else {

p = f_act / f_nf //integer division, drop remainder

r = f_act mod f_nf //remainder from integer division

if (p is even) then //Case 3

f_obs = r;

else if (p is odd) then //Case 4

f_obs = f_nf – r;

}

}

Algorithm 5.1

In the first case, when the actual frequency is less than or equal to the Nyquist frequency,

the sampling rate is sufficient and there is no aliasing. In the second case, when the actual

frequency is between the Nyquist frequency and the sampling rate, the observed frequency is

equal to the sampling rate minus the actual frequency. For example, a sampling rate of 1000 Hz

causes an 880 Hz sound wave to alias to 120 Hz (Figure 5.35).

Flash

Tutorial:

Nyquist and

Aliasing