Decode the technical header of a WAV file — its sample rate, channel count, bit depth, encoding and exact duration — without any player or upload. The inspector reads the RIFF/WAVE structure directly with the browser’s DataView API and stays entirely on your device.
How it works
A WAV file is a RIFF container. The first 12 bytes are the ASCII tag RIFF, a little-endian
4-byte total size, and the ASCII tag WAVE. After that comes a sequence of chunks, each one a
4-character ID, a little-endian 4-byte size, and that many bytes of payload (padded to an even
length).
The two chunks that matter are:
fmt → audio parameters
audioFormat (2 bytes) 1=PCM, 3=float, 6=A-law, 7=mu-law, 65534=extensible
numChannels (2 bytes)
sampleRate (4 bytes)
byteRate (4 bytes) = sampleRate × channels × bitDepth/8
blockAlign (2 bytes) = channels × bitDepth/8
bitsPerSample(2 bytes)
data → the raw samples; its size gives the audio payload length
The inspector walks the chunk list rather than assuming a fixed layout, so it correctly handles
files that place LIST or fact chunks before fmt or data.
Duration
Playback length comes straight from the data chunk:
duration (s) = data chunk size (bytes) ÷ byteRate
Because byteRate = sampleRate × channels × bitDepth / 8, a 10-second 44.1 kHz 16-bit stereo
clip has a data chunk of 10 × 44100 × 2 × 2 = 1,764,000 bytes.
Reading each field and what it means
sampleRate
The number of audio samples per second, per channel. Common values:
| Sample rate | Typical use |
|---|---|
| 8,000 Hz | Telephony, voice over IP |
| 22,050 Hz | Low-quality audio, older game audio |
| 44,100 Hz | CD audio, most consumer audio |
| 48,000 Hz | Professional video and broadcast standard |
| 96,000 Hz | High-resolution audio production |
If you see an unexpected sample rate like 22,050 Hz on a file you expected to be broadcast-quality, the file was either recorded at that rate or was downsampled. Resampling to a higher rate does not recover detail that was never captured.
numChannels
- 1 = Mono
- 2 = Stereo
- 6 = 5.1 surround (common in film audio)
- 8 = 7.1 surround
For surround formats, channel ordering follows the standard WAVE speaker assignment table (left front, right front, center, low-frequency, left back, right back, etc.).
bitsPerSample
- 8-bit: unsigned integer, low dynamic range, rarely used in modern audio
- 16-bit: CD standard, signed integer, 96 dB dynamic range
- 24-bit: studio production standard, signed integer, about 144 dB dynamic range
- 32-bit: often IEEE float (audioFormat = 3 rather than 1)
A 32-bit PCM file with audioFormat = 1 is signed integer with enormous headroom; a 32-bit file with audioFormat = 3 is floating-point, which can represent values outside the -1 to +1 range without clipping (used in intermediate processing stages).
blockAlign
Bytes per sample frame across all channels: numChannels × bitsPerSample / 8. For 16-bit stereo, blockAlign is 4 bytes. Audio players use this to seek to a specific time position without scanning through the data chunk.
audioFormat codes
- 1 (PCM): Uncompressed linear PCM. The most common and universally supported format.
- 3 (IEEE float): 32-bit or 64-bit floating-point samples. Common in digital audio workstations for headroom during mixing.
- 6 (A-law) / 7 (mu-law): Logarithmic compression used in telephony. Effectively 8-bit samples with companded dynamic range.
- 65534 (WAVE_FORMAT_EXTENSIBLE): A wrapper that stores the real format as a sub-format GUID in the extended fmt chunk. Used for high-channel-count and high-bit-depth audio where the original format codes are insufficient.
Tips
- A mismatch between the stored
byteRateandsampleRate × channels × bitDepth/8usually means a malformed or non-standard encoder — the inspector shows both so you can compare. - Format code
65534(extensible) wraps a real sub-format GUID; the bit depth and channels are still valid in the fmt chunk. - Very large declared sizes that exceed the actual file length indicate truncation or a streaming WAV written before the final size was known (a common output of live recording or network streaming that stopped unexpectedly).
LISTchunks carry metadata such as artist, copyright, and encoding software in plain ASCII;factchunks appear in compressed WAV formats and carry the sample count. Neither is required for PCM files, but they appear in practice and the inspector skips them correctly to findfmtanddata.