Useful Notes / WAV Audio

One of the most basic audio formats around, Waveform Audio File Format (WAV) files and other similar formats are essentially the on-disk equivalent of a CD.

While the WAV format can use a number of different encoding systems, simple Pulse-Code Modulation (PCM) is by far the most common, although Adaptive Differential PCM (ADPCM) is used by some games.

PCM can best be summed up as follows:

  1. Measure incoming signal voltage
  2. Store measurement as a number
  3. Wait a small fraction of a second
  4. Repeat steps 1 to 3 until end of recording

The end result of PCM encoding is a series of numbers corresponding to signal voltages at points in time. Older games use sampling rates as low as 8000 Hz, while the majority of games these days use the CD-quality 44100 Hz sampling-rate. Here, Hz means "samples per second", as opposed to the more conventional usage when talking about audio in general, which refers to how many peaks of a sound wave pass a certain point in a second.

The higher the sampling rate, the greater the range of frequencies which can be stored. The sampling theorem dictates that the highest frequency signal that can be stored is exactly half the sampling rate, known as the Nyquist Frequency. So, an 8000Hz sample-rate can encode sounds no higher than 4000Hz (enough to cover the important parts of human speech, and used by the telephone network for long-distance transmission), while a 48kHz sampling rate (standard on DVDs) can encode up to 24000Hz (a bit beyond the upper limit of human hearing).

The bit-depth determines how accurately the voltage is stored, and thus, the number of volume levels per sample. Early systems used 4 bits due to severely limited storage, and unsurprisingly, didn't sound very good. 8-bit samples and sound hardware became common in home computers in the late 1980s. By far the most common currently in use is 16-bit samples (which are used on CDs, among numerous other applications). In recent years, sound cards supporting 24-bit samples have shown up, along with some audio standards that use them, such as DVD-Audio. While there is a noticeable difference between 8-bit and 16-bit audio, the difference between 16-bit and 24-bit audio is slight enough that it will be lost if the playback is put through a cheap set of speakers.

A combination of sampling rate and bit-depth though increases the accuracy of the sound. CD-audio quality tends to look more blocky compared to the same audio sample encoded in DVD audio. But quality beyond DVD audio is very hard to tell (if any difference can be physically heard at all), but like 36-bit/48-bit color, it helps preserve accuracy of the sound sample when applying effects.

ADPCM is a variation on PCM that stores the differences between values, rather than the values themselves. By doing so, fewer bits can be used for each sample, but can still produce decent audio when played back, resulting in smaller files for a given recording. Unfortunately, a lot of software has no support for ADPCM encoding.

Due to the simplicity of WAV formats, they're well-suited for sounds that need to be mixed, such as sound-effects. When musicians go to the studio to record, their output is always taken down as WAV.