A CAF file is an 8-byte file header followed by chunks. Every field is big-endian, except the audio samples, whose byte order the format flags give. Floats are IEEE 754. The C-like structures in Apple’s specification are notation only: CAF data is not padded.
File header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | FourCC | mFileType | caff |
| 4 | 2 | u16 | mFileVersion | 1 for this specification |
| 6 | 2 | u16 | mFileFlags | 0 for version 1 |
Chunk header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | FourCC | mChunkType | the chunk type, below |
| 4 | 8 | s64 | mChunkSize | the size of the data section in bytes, without this header |
Types made only of lower-case letters, spaces and full stops are reserved by Apple. An
application’s own type must contain a character outside a–z,
space and full stop.
Chunk types
| Type | Chunk | Required | Page |
|---|---|---|---|
desc | audio description | always, straight after the file header | Audio description |
data | audio data | always, exactly one | Audio data |
pakt | packet table | when packets vary in size or frame count | Packet table |
chan | channel layout | over two channels, when order matters | Channel layout |
kuki | magic cookie | when the format needs one | Other chunks |
strg | strings | no | Other chunks |
mark | markers | no | Markers and regions |
regn | regions | no | Markers and regions |
inst | instrument | no | Other chunks |
midi | MIDI | no | Other chunks |
info | information | no | Other chunks |
edct | edit comments | no | Other chunks |
ovvw | overview | no | Other chunks |
peak | peak | no | Other chunks |
umid | unique material identifier | no, at most one | Other chunks |
uuid | user-defined | no | Other chunks |
free | free space | no | Other chunks |
Order of chunks
- The file header is first and
descfollows it immediately. - The
datachunk may appear anywhere afterdescif its size is known. With a size of −1, it must be the last chunk in the file. - The specification sets no other order, and
paktmay come before or afterdata. strg,mark,regn,infoandedctmay have a size larger than their contents, to leave room to grow.
Example
The start of a stereo file of 16-bit big-endian PCM at 44,100 Hz:
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 63 61 66 66 | caff |
| 4 | 00 01 | version 1 |
| 6 | 00 00 | flags 0 |
| 8 | 64 65 73 63 | desc |
| 12 | 00 00 00 00 00 00 00 20 | chunk size 32 |
| 20 | 40 E5 88 80 00 00 00 00 | sample rate 44100.0 |
| 28 | 6C 70 63 6D | format lpcm |
| 32 | 00 00 00 00 | flags 0: integer, big-endian |
| 36 | 00 00 00 04 | 4 bytes per packet |
| 40 | 00 00 00 01 | 1 frame per packet |
| 44 | 00 00 00 02 | 2 channels |
| 48 | 00 00 00 10 | 16 bits per channel |
| 52 | 64 61 74 61 | data |
| 56 | FF FF FF FF FF FF FF FF | size −1: unknown |
| 64 | 00 00 00 00 | edit count 0 |
| 68 | … | samples |