\n"); } else { header("Content-type: text/html; charset=utf-8"); } ?>
When sound is recorded digitally, a microphone first transforms changes in sound pressure level into voltage that varies in direct proportion to (is an anlog of) the sound pressure level (SPL) as it varies in time. To digitize the voltage, an analog to digital converter (ADC) samples the voltage at a certain rate, converting the voltage samples into a sequence of binary numbers that are stored in some sort of memory device, such as a disk file. To reconstruct the sound later, the binary numbers read back from storage and are fed into a digital to analog converter (DAC) at the same rate at which they were recorded. The DAC outputs a fixed voltage for each binary number it receives; a loudspeaker or headphone causes sound pressure level changes in proportion to the voltages it receives from the DAC.
This laboratory is a Java application that lets you see the effects of digitizing a sine wave. You can adjust two parameters to control the digitizing process: the sampling rate (samples per second) and the sampling resolution (bits per sample), and see their effects on the waveform that would be produced from the digitized values.
You can download the code and run it on any machine that has Java installed.
When you run the program, you will see three main panels, as shown in this screenshot:
The application consists of a Java jar file, so you need to have the Java runtime environment installed on your computer to run it. Most computers already have it installed.
Download the jar file for the program: AudioSampling.jar. Save it to a convenient spot, such as your desktop. You can then run the application by double-clicking on it or using the command, "java -jar AudioSampling.jar". Note: if your browser downloads the file as AudioSampling.jar.zip, just rename it to AudioSampling.jar before using it. Don’t unzip it.
If you would like to see/modify the code, the .java files are included in the jar
file, and you can extract them using the command:
jar xvf AudioSampling.jar AudioSampling.java EnumeratedVector.java
If you run the program from the command line, you can specify initial values for the signal frequency, sampling rate, and bits per sample as command line arguments. Use name=value pairs, where name is “frequency”, “rate”, “bitspersample”, or “bits” (the last two are equivalent). Also, the program’s audio playback feature can be disabled by specifying the “disableAudio” option on the command line. You can also set all these options as the program is running, so you don’t even need to know what “the command line” is in order to use the program.
You can use either command line arguments or the controls in the application to set the frequency of the signal to be digitized to a value between 0.1 and 25 KHz. (The upper limit of human hearing under ideal circumstances is about 20 KHz.) You can set the sampling rate to any value in the range of 0.1 to 50 KHz, but no higher than your computer’s audio system will support, normally 44.1 KHz. Bits per sample can range from 1 to 20, but large values will produce no visible effect in the generated waveform, and might slow the program down considerably. Like the sampling rate, this parameter cannot be set higher than the maximum value supported by your computer’s audio system.
The program can generate a tone based on the signal frequency, sampling rate, and bits per sample. There are a few thing to note about this feature:
As mentioned above, the source code for the application is embedded in the jar file. There are also two extra source files: one for experimenting with the sound system, and a second one that is not useful.