WAV/PCM Audio Format: The Lossless Audio Foundation
WAV (Waveform Audio File Format) is Microsoft and IBM's audio container format, introduced in 1991 as part of the Resource Interchange File Format (RIFF) specification. WAV is the standard for uncompressed audio — it stores raw PCM (Pulse Code Modulation) audio data without any lossy compression. Understanding WAV's structure explains why it is the universal format for professional audio production, sample libraries, and any workflow where audio quality cannot be compromised.
The RIFF/WAV Structure
WAV uses the RIFF (Resource Interchange File Format) chunk hierarchy:
RIFF chunk
ChunkID: "RIFF" (4 bytes)
ChunkSize: file_size - 8 (4 bytes, little-endian)
Format: "WAVE" (4 bytes)
fmt chunk (format descriptor)
ChunkID: "fmt " (4 bytes, note trailing space)
ChunkSize: 16, 18, or 40 (4 bytes)
AudioFormat: 1=PCM, 3=IEEE float, 6=A-law, 7=μ-law, 65534=WAVE_FORMAT_EXTENSIBLE
NumChannels: 1=mono, 2=stereo, 6=5.1, 8=7.1 (2 bytes)
SampleRate: 8000, 44100, 48000, 96000, 192000 Hz (4 bytes)
ByteRate: SampleRate × NumChannels × BitsPerSample/8 (4 bytes)
BlockAlign: NumChannels × BitsPerSample/8 (2 bytes)
BitsPerSample: 8, 16, 24, 32 (2 bytes)
[ExtraParamSize: 0, 2, or 22 bytes for non-PCM formats]
[LIST chunk — optional metadata]
ChunkID: "LIST"
Type: "INFO"
[INAM: track name]
[IART: artist]
[ICRD: creation date]
[ISFT: software]
data chunk (audio sample data)
ChunkID: "data"
ChunkSize: NumSamples × NumChannels × BitsPerSample/8
Data: interleaved sample data (LRLRLR... for stereo)
The fmt chunk defines the audio format completely. The data chunk contains raw sample values, interleaved by channel: for stereo, samples are stored Left1, Right1, Left2, Right2, Left3, Right3...
PCM: Pulse Code Modulation Explained
PCM is the digital representation of analog audio. The analog waveform is sampled at regular intervals:
-
Sampling: The amplitude of the audio waveform is measured at regular time intervals (the sample rate). At 44100 Hz, 44,100 measurements are taken per second.
-
Quantization: Each measurement is rounded to the nearest value in a grid of discrete levels (determined by bit depth). At 16-bit, there are 2^16 = 65,536 possible levels (−32,768 to +32,767). At 24-bit, there are 16,777,216 levels.
-
Encoding: The quantized values are stored as integers (or floats for 32-bit IEEE float).
Quantization noise: Rounding to the nearest discrete level introduces a small error — the difference between the true analog value and the stored integer. This error is called quantization noise. Higher bit depth = smaller quantization steps = less quantization noise.
Bit Depth Reference
| Bit Depth | Dynamic Range | Quantization Noise Floor | Typical Use |
|---|---|---|---|
| 8-bit | 48 dB | −48 dB | Legacy; speech telephony |
| 16-bit | 96 dB | −96 dB | CD audio; consumer standard |
| 24-bit | 144 dB | −144 dB | Professional recording; DAW sessions |
| 32-bit int | 192 dB | −192 dB | Rarely used (32-bit float preferred) |
| 32-bit float | ~1500 dB | Near zero | DAW internal processing; render targets |
Human hearing has a dynamic range of approximately 120 dB. 16-bit's 96 dB is slightly below this (hence dithering for CD mastering). 24-bit at 144 dB provides 24 dB of headroom above audible noise — sufficient for any professional recording scenario.
Sample Rates
| Sample Rate | Nyquist Limit | Use Case |
|---|---|---|
| 8,000 Hz | 4,000 Hz | Telephony (GSM) |
| 11,025 Hz | 5,512 Hz | Legacy multimedia |
| 16,000 Hz | 8,000 Hz | VoIP, speech recognition |
| 22,050 Hz | 11,025 Hz | Half-rate CD |
| 44,100 Hz | 22,050 Hz | CD, consumer standard |
| 48,000 Hz | 24,000 Hz | Professional video, broadcast |
| 88,200 Hz | 44,100 Hz | High-res audio (double CD) |
| 96,000 Hz | 48,000 Hz | Professional studio |
| 192,000 Hz | 96,000 Hz | Ultra high-res archival |
The Nyquist theorem states that a sample rate of Fs can represent frequencies up to Fs/2. Human hearing extends to approximately 20,000 Hz, so 44,100 Hz (Nyquist 22,050 Hz) is sufficient. Higher sample rates are used to avoid aliasing during digital processing and to capture ultrasonic content for dog/bat research (joke aside, it's mainly for processing headroom).
WAVE_FORMAT_EXTENSIBLE
For more than 2 channels or bit depths beyond 16, WAV uses the WAVE_FORMAT_EXTENSIBLE format (AudioFormat = 65534 = 0xFFFE):
WAVE_FORMAT_EXTENSIBLE:
wValidBitsPerSample: 24 (actual bits used, e.g., 24 in a 32-bit container)
dwChannelMask: speaker position bitmask
0x3 = FL, FR (stereo)
0x3F = FL, FR, FC, LFE, BL, BR (5.1)
0x63F = FL, FR, FC, LFE, BL, BR, SL, SR (7.1)
SubFormat: GUID identifying actual codec (PCM, IEEE float, etc.)
The dwChannelMask explicitly maps each channel to a speaker position (Front Left, Front Right, Center, LFE/subwoofer, etc.), preventing ambiguity in surround sound files.
File Size Calculations
File size = SampleRate × NumChannels × (BitsPerSample/8) × DurationSeconds + 44 bytes (header)
Examples:
CD quality (44.1 kHz, 16-bit, stereo, 1 min):
44100 × 2 × 2 × 60 = 10,584,000 bytes ≈ 10.1 MB/minute
Studio quality (96 kHz, 24-bit, stereo, 1 min):
96000 × 2 × 3 × 60 = 34,560,000 bytes ≈ 33 MB/minute
Podcast (44.1 kHz, 16-bit, mono, 1 hour):
44100 × 1 × 2 × 3600 = 317,520,000 bytes ≈ 303 MB
Working with WAV Files
ffmpeg
# Convert MP3 to WAV (16-bit, 44.1 kHz)
ffmpeg -i input.mp3 -ar 44100 -ac 2 -c:a pcm_s16le output.wav
# Convert to 24-bit WAV (professional quality)
ffmpeg -i input.mp3 -ar 96000 -ac 2 -c:a pcm_s24le output_24bit.wav
# Convert WAV to MP3
ffmpeg -i input.wav -c:a libmp3lame -b:a 320k output.mp3
# Convert WAV to FLAC (lossless, smaller)
ffmpeg -i input.wav -c:a flac output.flac
# Extract audio from video as WAV
ffmpeg -i video.mp4 -vn -c:a pcm_s16le audio.wav
# Trim WAV (from 30s to 90s)
ffmpeg -i input.wav -ss 00:00:30 -t 00:01:00 -c copy output_trimmed.wav
# Change sample rate (resample)
ffmpeg -i input_48k.wav -ar 44100 -c:a pcm_s16le output_44k.wav
# Mix two audio files
ffmpeg -i track1.wav -i track2.wav -filter_complex "[0][1]amix=inputs=2:duration=longest" output.wav
SoX (Sound eXchange)
# Convert sample rate with high-quality resampling
sox input.wav -r 48000 output_48k.wav
# Apply dithering when reducing bit depth
sox input_24bit.wav -b 16 output_16bit.wav dither
# Normalize audio level to 0 dBFS
sox --norm input.wav output_normalized.wav
# Split stereo into two mono files
sox input_stereo.wav output_left.wav remix 1
sox input_stereo.wav output_right.wav remix 2
WAV vs. FLAC vs. AIFF vs. MP3
| Format | Compression | Quality Loss | File Size | Platform |
|---|---|---|---|---|
| WAV (PCM) | None | Zero | ~10 MB/min | Universal |
| FLAC | Lossless | Zero | ~5 MB/min | All except iOS native |
| AIFF | None (or lossless) | Zero | ~10 MB/min | Apple-native |
| MP3 | Lossy | Yes | ~0.6-2.4 MB/min | Universal |
| AAC | Lossy | Yes | ~0.5-1.5 MB/min | Near-universal |
| Opus | Lossy | Yes | ~0.05-0.7 MB/min | Near-universal |
When to use WAV: Audio production (DAW source and render format), sample libraries (game audio, music production), broadcast delivery (many broadcasters specify WAV for final deliverables), and any context where future processing must not be compromised by existing compression artifacts.
When to use FLAC instead: Archives where storage efficiency matters. FLAC is losslessly identical to WAV but typically 50-60% smaller. Convert WAV → FLAC for archival, FLAC → WAV for DAW import if needed.
Summary
WAV/PCM is the bedrock of digital audio — simple, universal, and lossless. Its RIFF chunk structure is straightforward to parse, its PCM data requires no decoding (raw sample values read directly), and its format parameters are explicitly declared. The cost is file size: at CD quality, WAV is ~10 MB per minute vs. ~1 MB for MP3. For distribution, compress to Opus/MP3/AAC. For production, editing, and archival where every sample must be preserved, WAV or its lossless-compressed equivalent FLAC is the correct choice.
Related conversions
Audio format pairs that come up most often: