The Big Picture: Turning a Wave into a List of Numbers

A real sound wave is smooth. A computer can only store a list of numbers. The trick is to measure the wave very many times per second and write each measurement down. Each measurement is called a sample. Play the samples back in order, at the same speed, and a DAC can rebuild the wave.

Think of a flip-book. Each page is a still picture, but flip fast enough and you see smooth movement. Audio samples work the same way, only with thousands of "pages" every second.

 height of wave
   │      ·        ·
   │   ·     ·  ·     ·            each dot = one sample
   │ ·         ·        ·
   │──────────────────────── time
   │                       ·    ·
   │                          ·
   samples:  4  7  9  7  4  0 -4 -7 ...   (just numbers!)

Two settings decide how good the copy is: how often you measure (sample rate) and how precisely you write each number (bit depth).

5.1 Sampling Rate

What it is: The sample rate is how many times per second the wave is measured. It is given in hertz (Hz); 1 kHz is 1,000 Hz.

Sample rateWhere you see it
44,100 Hz (44.1 kHz)Audio CDs, many music files
48,000 Hz (48 kHz)Common for video and for PC audio
96,000 and 192,000 Hz"High-resolution" audio

Why these numbers? The Nyquist rule. To capture a sound, you must sample at more than twice its highest pitch. This is the Nyquist limit. Human hearing reaches roughly 20 Hz to 20,000 Hz (20 kHz), and most adults hear less at the top end. Twice 20 kHz is 40 kHz, so 44.1 kHz is enough to cover everything a human can hear, with a little room for the filters. Higher rates catch ultrasonic sounds that people cannot hear, but they help with editing and processing, and take more space.

What if you sample too slowly? Fast vibrations get recorded as false slow ones. This is called aliasing, like wagon wheels that seem to spin backwards in old films. Converters filter out the too-high pitches before sampling to avoid it.

Mixing different rates. If a song is 44.1 kHz but the device is set to 48 kHz, the audio engine converts between them (sample-rate conversion, Section 3). It is done well and is almost never noticeable.

5.2 Bit Depth

What it is: Bit depth says how many bits each sample uses. More bits mean the wave height can be written down more finely.

Bit depthNumber of levelsApproximate range from quietest to loudest (dynamic range)
8-bit256about 48 dB (old, hissy)
16-bit65,536about 96 dB (CD quality)
24-bit16.7 millionabout 144 dB in theory (more than any real equipment reaches)

(dB, decibel, is the unit used for loudness differences. Roughly, each extra bit adds about 6 dB of dynamic range.)

Think of a ruler. A ruler marked only in whole centimetres gives rough readings (low bit depth). A ruler marked in millimetres is more precise (high bit depth). The small error from rounding to the nearest mark shows up as a faint hiss called quantisation noise. With 16-bit audio it is very quiet. 24-bit is mostly used in recording and editing, where extra headroom helps when you apply many changes. Windows also uses 32-bit floating-point numbers inside the audio engine, so mixing does not lose accuracy.

5.3 Digital-to-Analogue Conversion (DAC)

What it is: The DAC (introduced in Section 1) turns the stream of samples back into a smooth electric wave.

How it works in plain words:

  1. Each sample number is turned into an electric voltage: a bigger number gives a bigger voltage.
  2. The voltage is held for one sample time, so the output looks like a staircase.
  3. A filter smooths the stairs into a curve.
  4. An amplifier makes it strong enough to drive headphones or speakers.
 samples (numbers)      DAC output (steps)       after filter (smooth)
   4 7 9 7 4 0          ▄▄▅▅▇▇▅▅▄▄▁▁             ╭──╮
                                                 ─╯    ╰─

The ADC works in reverse: it measures the microphone voltage at each tick and writes down the nearest number.

5.4 PCM, Channels and Data Rate

PCM (Pulse-Code Modulation) is the plain, raw form of digital audio: just the list of samples, nothing squeezed. A .wav file is usually PCM inside a small wrapper.

Channels are separate streams for different speakers:

LayoutChannelsUsed for
Mono1Voice calls, microphones
Stereo2 (left and right)Most music
5.16 (front L/R, centre, subwoofer, rear L/R)Movies. The ".1" is the low-bass channel

How much data is that? Multiply the three settings:

data rate  =  sample rate  ×  bit depth  ×  channels

CD audio   =  44,100  ×  16  ×  2  =  1,411,200 bits per second
           ≈  1.4 Mbit/s  ≈  176,400 bytes per second  ≈  10 MB per minute

So a 4-minute song in raw PCM is about 40 MB.

5.5 Compression: Lossless and Lossy

Raw PCM is large, so most music files are compressed. There are two kinds.

LosslessLossy
IdeaLike a ZIP file: shrinks the data, and the exact original comes backThrows away detail you are unlikely to notice
ExamplesFLAC, ALAC (Apple), WAV (usually not compressed at all)MP3, AAC, Opus
Typical sizeRoughly half of PCM (varies with the music)Often about 10 percent of PCM or less
QualityIdentical to the originalVery good at normal settings, but not identical

Lossy formats rely on how human hearing works: a loud sound hides quieter sounds close to it in pitch and time, and we hear very high pitches poorly. The encoder removes what is least likely to be heard. Once removed, it cannot be restored, so avoid re-saving a lossy file again and again.

Where does decoding happen? A decoder turns the compressed file back into PCM samples. In Windows the player app (using Media Foundation or its own library) does this before anything reaches the audio engine. The engine only deals with PCM (Section 7).

Summary

TermPlain meaning
SampleOne measurement of the wave height
Sample rateMeasurements per second (44.1 kHz for CDs, 48 kHz common on PCs)
Nyquist ruleSample at more than twice the highest pitch you want to keep
Bit depthHow finely each sample is written (16-bit about 96 dB range)
DACTurns samples into a smooth voltage wave
PCMRaw, uncompressed samples
ChannelsMono 1, stereo 2, 5.1 is 6
CD data rate44,100 × 16 × 2 = 1,411,200 bit/s (about 1.4 Mbit/s)
LosslessFLAC, ALAC, WAV: exact original comes back
LossyMP3, AAC, Opus: small files, detail removed for good