I’m a physics teacher, and one of the topics in our curriculum is how sound waves are digitized. I’ve been told by other teachers that previous versions of Audacity could be used to show how aliasing happens (Audacity is the software our textbook recommends for this as well), but can’t get it to work now.
What I want to do is to either generate a tone, or record a tone from a tuning fork, with the sampling frequency deliberately set too low, and show how this changes the frequency of the recorded tone.
When I manually set the sampling frequency too low in Audacity, I record very little sound at all. There is some noise, but so low I think it’s just background noise. It doesn’t seem to record the tone at all.
If you are recording, the soundcard (or driver) will filter appropriately to avoid aliasing.
There are options in the Generate menu to generate a “Square Wave” or “Square Wave (No Alias)” but I tried both options and it would not allow me to enter a frequency above the Nyquist limit.
The best approach might be to generate waveforms using the [u]Nyquist Language[/u], so you’re just doing “pure math”.
Open Audacity and ensure that the Project Rate is set to 44100 (bottom left corner of the main screen). This is the default rate for Audacity.
Add a new track (Tracks menu > Add New > Mono track) and select part of it (a selection is required to run effects).
Open the Nyquist Prompt effect (Edit menu).
We are now going to use a simple Nyquist commands to generate a sine tone at a specific frequency. (The index of the Nyquist manual is here if you wish to look up these commands: Index). Nyquist will not apply anti-aliasing unless we specifically tell it to, so that makes it easy to demonstrate the effect.
We know that our sample rate is 44100, and the Nyquist Shannon theorem tells us that the highest supported frequency is half the sample rate, so let’s first try generating a tone that is within that range. Enter the following code into the Nyquist Prompt:
Now try it with a frequency of 34100 Hz. We know this should not be possible, so we expect to see either nothing (if an anti-alias filter is applied), or the tone will be aliased as a 10000 Hz tone (if there is no anti-alising filter).
If you use the “Debug” button instead of the “OK” button, you will see a warning about aliasing.
(hzosc 34100)
Now set the Project Rate to 96000 Hz (or higher) and add a new track. The new track takes the Project Rate as its default sample rate.
Repeat the above tests. You will now see the 34100 Hz tone generated “correctly”.