The fact chunk gives the length of the audio in sample frames. For PCM the
length follows from the data size, but for compressed audio it does not, so the WAV
specifications require a fact chunk in every file that is not PCM, and a
BW64 file follows them.
Fields
Offsets are from the start of the chunk. Numbers are little-endian.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | char[4] | ckID | fact |
| 4 | 4 | u32 | ckSize | 4, or more if later fields are added |
| 8 | 4 | u32 | dwSampleLength | the number of sample frames, that is samples for each channel; 0xFFFFFFFF when the count does not fit in 32 bits |
The 1991 RIFF specification names the field dwFileSize, “Number of
samples”, and adds that “Added fields will appear following the <dwFileSize>
field.” None has been defined.
Counts past 32 bits
A count of 0xFFFFFFFF means the real count is in the third field of the
ds64 chunk, at offset 16
of its data, as a u64; Tech 3306 calls it sampleCount. The explorer
follows it. libbw64, the EBU’s reference library, names the same field
dummySize and writes 0 there, so a reader should not count on it.
00000000 66 61 63 74 04 00 00 00 FF FF FF FF fact........
When the count is not 0xFFFFFFFF, it is the count. In an RF64 test file
seen for this site, from SciPy, the ds64 frame count was 41,745 while the
fact chunk said 4,410, which matched the data: trust fact
when its count is real.
When it appears
- The 1991 specification requires it for every compressed format; Microsoft’s 1994 revision for every format that is not PCM. So ADPCM, A-law, µ-law, GSM and MP3 data have one.
- Floating point and extensible files: many writers add one, and some readers expect it.
- Integer PCM: optional, since the frame count is the data size divided by the block align.
For ADPCM the last block is often short, and the fact count is the only
exact length; the explorer takes the frame count from it. For PCM, G.711 and float the
explorer counts the frames in the data chunk and shows the fact count beside
them when the two differ.