Tools for Digital Sound
Sound is the oscillation of pressure that propagates in the form of a wave. Sound waves are transmitted through some medium (solid, liquid, or gas); they cannot travel through a vacuum. The human ear detects the pressure changes and decodes this into what we hear. Sound can be converted into an electrical signal using microphones or other transducer, by which pressure changes become voltage changes. The reverse, converting voltage changes into pressure changes, can be done via speakers. An analog audio signal may be visualized by plotting the voltage as a function of time (e.g., using an oscilloscope). Note that the voltage level and time are continuous quantities. Pulse code modulation (PCM) is one method for digitally representing an audio signal, and is the standard used for compact discs (music CDs) and computer sound. A PCM stream is obtained from an audio signal by discretizing both the voltage level and time. Time is discretized by choosing a uniform sampling rate, measured as the number of samples taken per second. Each sample is a discretized measure of the voltage level. The resolution of the samples is governed by the bit depth; namely, the number of bits allowed for each sample. For example, Figure 2 shows a digitized signal using a sample rate of 10 samples per second, and a resolution of 3 bits using the 8 possible values: -3, -2, -1, 0, 1, 2, 3, 4 (this would be horribly poor quality for an audio signal). The difference between the sample and the actual signal level is known as the quantization error; using a higher bit depth reduces this. The sampling rate determines the highest frequency that can be correctly recovered from the sampled data. This is known as the Nyquist frequency and is half of the sampling rate. Compact discs use 16 bits of resolution (per channel) and 44,100 samples per second | enough to recover the entire range of human hearing (20 Hz to 20,000 Hz). For this project, you will write some programs to manipulate and generate PCM streams. You will work entirely with uncompressed streams (e.g., .wav files); popular formats like .aac, .m4a and .mp3 instead use lossy compression on the stream to reduce the storage requirements.