Audio Binary Sampling

How sound waves become sequences of 0s and 1s in digital audio

Sound Is Analog, Computers Are Binary

Sound is a physical wave — a continuous variation in air pressure traveling through the air. When you speak, your vocal cords create pressure waves that the human ear interprets as sound. A computer cannot store a continuous wave. It can only store discrete binary numbers. This creates a fundamental problem: how do you convert an infinite, continuous phenomenon into finite binary data?

The answer is sampling. A microphone converts air pressure into an electrical voltage. An analog-to-digital converter (ADC) measures that voltage at precise intervals and outputs a binary number representing the voltage level at that instant. If you take enough measurements per second and record each one with enough precision, the sequence of binary numbers reconstructs the original sound wave with remarkable fidelity. I still find it amazing that a song streaming on Spotify is just a long, fast sequence of binary samples.

Key Insight: A 3-minute song at CD quality (44.1 kHz, 16-bit stereo) contains 15,876,000 individual binary samples — roughly 31.7 million bytes of PCM data before compression.

Sampling Rate: How Often We Measure

The sampling rate determines how many times per second the ADC measures the audio signal. It is measured in kilohertz (kHz). CD-quality audio uses 44,100 samples per second (44.1 kHz). Professional audio often uses 48 kHz, 96 kHz, or even 192 kHz. Each sample is a single binary number representing the voltage at that precise moment in time.

The Nyquist-Shannon theorem states that to accurately capture a frequency, you must sample at least twice that frequency. Since human hearing ranges from about 20 Hz to 20 kHz, 44.1 kHz provides a safe margin above the 40 kHz minimum required to capture 20 kHz. This is why 44.1 kHz became the CD standard — it covers the full range of human hearing with some headroom. Sampling below the Nyquist rate causes aliasing, where high frequencies fold back and create false low-frequency artifacts that sound terrible.

Bit Depth: How Precise Each Measurement Is

Bit depth determines how many possible amplitude levels each sample can represent. A 16-bit sample can represent 65,536 different voltage levels (from -32,768 to +32,767 in signed representation). An 8-bit sample can only represent 256 levels. Each additional bit doubles the precision. The impact on audio quality is dramatic, especially for quiet passages and dynamic range.

Think of it this way: with 16-bit audio, the quietest detectable sound is 1/65,536th of the maximum volume, giving a theoretical dynamic range of about 96 dB. With 24-bit audio (16,777,216 levels), the dynamic range jumps to 144 dB — enough to capture everything from a whisper to a jet engine. In my experience, 24-bit recording makes a noticeable difference in classical music and other genres with wide dynamic range, while 16-bit is perfectly adequate for most modern pop music that is heavily compressed anyway.

PCM: The Raw Binary Audio Format

Pulse Code Modulation (PCM) is the simplest and most fundamental digital audio format. It stores audio as a raw sequence of binary samples with no compression. A WAV file is essentially PCM data with a 44-byte header. The binary structure of PCM audio is straightforward: for stereo 16-bit audio, each sample period produces 4 bytes — 2 bytes for the left channel and 2 bytes for the right channel, interleaved.

Here is what a tiny segment of 16-bit PCM stereo audio looks like in binary:

  • Sample 1, Left: 00000000 00000000 (silence)
  • Sample 1, Right: 00000000 00000000 (silence)
  • Sample 2, Left: 00000000 10011001 (153, small positive)
  • Sample 2, Right: 00000000 10011001 (153, small positive)
  • Sample 3, Left: 00000001 00110010 (306, larger positive)

Each 16-bit value uses two's complement signed representation, meaning the first bit indicates the sign (0 for positive, 1 for negative). A value of 0 is silence. The closer the binary number gets to 01111111 11111111 (32,767), the louder the positive half of the wave. Values near 10000000 00000000 (-32,768) represent the negative peak of the wave.

44.1 kHz vs 48 kHz: Why the Difference Matters

You see both 44.1 kHz and 48 kHz everywhere, but they are not interchangeable. CD audio standardized on 44.1 kHz for historical reasons related to the limitations of early PCM adapters and video tape storage. DVD and broadcast video standardized on 48 kHz because it divides evenly into video frame rates — exactly 1,600 samples per 1080p frame at 30 fps.

Converting between the two requires sample rate conversion, which always introduces some (usually imperceptible) artifacts. This is why professional audio work often picks one sample rate and sticks with it throughout the entire production chain. In practice, 44.1 kHz is perfectly fine for music distribution, and 48 kHz is standard for video production. Higher rates like 96 kHz are used in production for headroom during processing, but there is no audible benefit for final distribution.

Binary Audio Storage Sizes

I often calculate audio storage requirements for projects, and the math is simple once you know the formula: sample rate × bit depth × channels × duration in seconds = raw bit size. Here are some real-world examples:

  • CD quality (44.1 kHz, 16-bit, stereo): 44,100 × 16 × 2 = 1,411,200 bits/sec = 176.4 KB/sec. A 3-minute song = about 31.7 MB.
  • DVD quality (48 kHz, 16-bit, 5.1 surround): 48,000 × 16 × 6 = 4,608,000 bits/sec = 576 KB/sec. A 2-hour movie = about 4.14 GB of audio alone.
  • Studio quality (96 kHz, 24-bit, stereo): 96,000 × 24 × 2 = 4,608,000 bits/sec = 576 KB/sec. A 1-hour recording session = about 2.07 GB.

These raw sizes explain why lossy compression like MP3 and AAC exists. A 3-minute CD-quality song compressed to 320 kbps MP3 is only 7.2 MB instead of 31.7 MB — a 77% reduction. The compression works by removing audio content that the human ear cannot perceive, based on psychoacoustic models of auditory masking.

The WAV File Binary Structure

A WAV file is probably the easiest audio format to understand at the binary level. It starts with a 44-byte header followed by the raw PCM sample data. The header contains:

  • Bytes 0-3: 52494646 ("RIFF" in ASCII)
  • Bytes 4-7: File size minus 8 (32-bit little-endian integer)
  • Bytes 8-11: 57415645 ("WAVE" in ASCII)
  • Bytes 12-15: 666D7420 ("fmt " in ASCII)
  • Bytes 16-19: Subchunk size (16 for PCM)
  • Bytes 20-21: Audio format (1 = PCM)
  • Bytes 22-23: Number of channels (1 = mono, 2 = stereo)
  • Bytes 24-27: Sample rate (e.g., 44100)
  • Bytes 28-31: Byte rate (sample rate × channels × bits/8)
  • Bytes 32-33: Block align (channels × bits/8)
  • Bytes 34-35: Bits per sample
  • Bytes 36-39: 64617461 ("data" in ASCII)
  • Bytes 40-43: Size of data section

After the header, the raw binary samples follow in a continuous stream. The simplicity of the WAV format makes it perfect for learning about binary audio. You can read and write WAV files with nothing more than basic binary I/O, and the samples are immediately usable for analysis or processing.

Hands-On: Open any WAV file in a hex editor and look for the RIFF and WAVE markers. The binary sample data starts right after the "data" header and the 4-byte size field.

Try It Yourself

Open the Binary Code Decoder in a new tab and enter some binary patterns to see the results instantly. All conversions happen in your browser — no data is sent to any server.