WAV fmt chunk

Field layout of the WAV fmt chunk, audio format codes such as PCM, float and extensible, and how to read them from the raw bytes.

Field layout

The fmt chunk describes how the samples in data are encoded. Its ID ends in a space (66 6d 74 20) because every chunk ID is exactly four bytes. The payload follows the WAVEFORMATEX structure from Microsoft. In the hex view, offsets count from the start of the selected chunk, so the first payload byte is at 0x08, after the 4-byte ID and the 4-byte size.

Payload offsetHex viewBytesField
00x082Format code
20x0A2Channels
40x0C4Sample rate
80x104Byte rate
120x142Block align
140x162Bits per sample
160x182Extension size (cbSize), only when the chunk is 18 bytes or more
180x1AcbSizeExtension bytes

Format codes

The first two bytes name the encoding. These are the codes you are most likely to meet, with the bytes as they appear in the hex view.

CodeBytesEncoding
0x000101 00PCM integer
0x000202 00Microsoft ADPCM
0x000303 00IEEE float, 32 or 64 bit
0x000606 00A-law
0x000707 00µ-law
0x001111 00IMA ADPCM
0x005555 00MPEG Layer 3
0xFFFEfe ffExtensible: the real code is in the SubFormat GUID

Chunk sizes of 16, 18 and 40

A 16-byte fmt chunk is plain PCM with no extension field. An 18-byte chunk adds cbSize, usually set to 0. A 40-byte chunk is WAVE_FORMAT_EXTENSIBLE: cbSize is 22 and is followed by valid bits per sample (2 bytes), a channel mask (4 bytes) and a 16-byte SubFormat GUID whose first two bytes hold the real format code, 1 for PCM or 3 for float.

Microsoft recommends the extensible form for more than two channels, for more than 16 bits per sample, and whenever the speaker layout must be stated. Channel mask bits are 0x1 front left, 0x2 front right, 0x4 front centre, 0x8 LFE, 0x10 back left and 0x20 back right, so 0x3F is 5.1 with back speakers.

Checks you can do by hand

Block align should equal channels times bits per sample divided by 8, and byte rate should equal sample rate times block align. In the sample both hold: 1 × 16 / 8 = 2 and 8000 × 2 = 16000. If they disagree, the file was written by buggy software and players may handle it differently.

The RIFF specification asks for a fact chunk in every file whose format is not PCM. It holds the number of sample frames as a 4-byte value. If your float or compressed file has one, it shows up as its own chunk in the tree.

The viewer does not decode these fields for you. It shows the raw bytes, which is what you need when a tool reports the wrong format and you want to see what the file contains.

RIFF Viewer showing tone.wav: a RIFF WAVE chunk holding fmt (16 bytes) and data (4,000 bytes), with fmt selected and its sample rate bytes highlighted in the hex view.
The sample WAV in the viewer with fmt selected. The sample rate sits at 0x0C: 40 1F 00 00, which is 8000.

Questions

Why does the fmt chunk ID have a space in it?

Chunk IDs are always four bytes, so the three-letter name is padded with a space: fmt .

What does audio format 65534 mean?

65534 is 0xFFFE, WAVE_FORMAT_EXTENSIBLE. Look at the first two bytes of the SubFormat GUID at payload offset 24 to find the real encoding.

Should a 24-bit WAV file use the extensible format?

Microsoft’s guidance says yes, but many files use format code 1 with 24 bits anyway. Check the bytes at 0x08 in the hex view to see which one your file uses.

Where is the bit depth stored?

At payload offset 14, shown at 0x16 in the hex view, as a 2-byte little-endian number.

Open the RIFF Viewer with your own file, or download the sample used above.