Audio Sampling Laboratory

Introduction

This is a Java application that lets you see the effects of sampling rate and bits-per-sample on the shape of an analog waveform when it is digitized. Here is a screen shot. (You can increase your browser’s text size to zoom in.):

screenshot

When sound is recorded digitally, a microphone transforms changes in sound pressure level to voltages that are a direct analog of the sound pressure level as it varies in time. To digitize the voltage, an analog to digital converter (ADC) samples the voltage at a certain rate, converting each voltage sample into a binary number. To reconstruct the sound later, the binary numbers 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.

When you run the program, you will see three main panels:

Downloading and Running the Application

Downloading

The application consists of a Java jar file, so you need to have the Java runtime environment installed on your computer to run it. Download the jar file: AudioSampling.jar. Save it to a convenient spot, such as your desktop. You can then run the application by double-clicking on it (Windows, OS X) or using the command, "java -jar AudioSampling.jar" (all systems). Note: if your browser downloads the file as AudioSampling.jar.zip, just rename it to AudioSampling.jar; don’t unzip it.

Start-up and run-time options.

If you run the program from the command line, you can specify initial values for the signal frequency, sampling rate, and bits per sample on the command line. 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.

Using either command line arguments or the controls in the application, the signal frequency may be set to a value between 0.1 and 25 KHz. (The upper limit of human hearing under ideal circumstances is about 20 KHz.) Sampling rate values may be set to any value in the range of 0.1 to 50 KHz, but cannot be set any higher than your computer’s audio system will support, normally 44.1 KHz. Bits per sample can range from 1 to 20, but values 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.

Audio Playback

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:

Source Code

The source code for the application, along with some classes for experimenting with the Java Sampled Audio package, are embedded in the jar file. You can import the jar file as an Eclipse project if you want to work on the source code instead of just running it.