The chunks not covered on the other pages. Each is optional, except that
kuki is required for formats that need it.
kuki: magic cookie
Data the codec needs, in a format of its own. For AAC, it is the contents of the
esds atom of an MPEG-4 file. The specification leaves the layout to each
format; this is what each looks like in the files on this Mac and in files made with
afconvert. A reader must not need a cookie for formats that have none:
linear PCM, µ-law, A-law, IMA4 and MPEG audio have no kuki chunk.
AAC (and HE-AAC, AAC-LD, AAC-ELD): MPEG-4 descriptors
The cookie is the ES_Descriptor of ISO/IEC 14496-1 (clause 7.2.6), as in the MP4
esds box. It is written with a 4-byte version-and-flags field first in some
files, or as the whole esds box; the explorer finds the descriptor in all
three. Each descriptor is a tag byte, a length of 1 to 4 bytes (7 bits each, the top bit
says another follows; Apple writes 4 bytes, 80 80 80 nn), then its fields:
| Descriptor | Tag | Fields |
|---|---|---|
| ES_Descriptor | 03 | ES_ID (u16, 0), flags (u8: bit 7 streamDependence, bit 6 URL, bit 5 OCR, low 5 bits priority), then optional dependsOn_ES_ID (u16), a URL (length byte and text), OCR_ES_Id (u16); then the descriptors below |
| DecoderConfigDescriptor | 04 | objectTypeIndication (u8: 40 MPEG-4 audio, 66 to 68 MPEG-2 AAC, 69 and 6B MP3), streamType (u8: type << 2 | upstream << 1 | 1; 5 for audio gives 15), bufferSizeDB (u24), maxBitrate (u32), avgBitrate (u32), then DecoderSpecificInfo |
| DecoderSpecificInfo | 05 | the AudioSpecificConfig of ISO/IEC 14496-3: audio object type (5 bits, 31 means 32 plus 6 more bits), sampling frequency index (4 bits, 15 means a 24-bit rate follows), channel configuration (4 bits), then the tools’ fields. HE-AAC adds, after the 3 GASpecificConfig bits, the sync word 0x2B7, object type 5 (SBR), an SBR-present flag and the output sampling frequency index, and for parametric stereo 0x548 and a flag |
| SLConfigDescriptor | 06 | predefined (u8): 2 for MP4 |
An AAC LC stereo cookie at 48,000 Hz from /Library/Audio/Apple Loops
(39 bytes):
| Bytes | Meaning |
|---|---|
03 80 80 80 22 | ES_Descriptor, 34 bytes |
00 00 00 | ES_ID 0, no flags |
04 80 80 80 14 | DecoderConfigDescriptor, 20 bytes |
40 15 00 18 00 | MPEG-4 audio, audio stream, buffer 6,144 bytes |
00 01 61 88 00 01 F4 00 | maximum 90,504 bit/s, average 128,000 bit/s |
05 80 80 80 02 11 90 | DecoderSpecificInfo: 0001 0001 1001 0000 = AAC LC (2), index 3 (48,000 Hz), 2 channels |
06 80 80 80 01 02 | SLConfigDescriptor, predefined 2 |
The cookie’s rate and channels must agree with the audio description (for HE-AAC the core rate is the description’s, and the cookie also gives the output rate); the explorer marks a difference.
Apple Lossless
Apple’s ALACSpecificConfig, 24 bytes, big-endian, optionally preceded by the MP4 atoms
frma (12 bytes) and alac (12 bytes: size, type, version and
flags) and followed by a 24-byte chan atom (size 24, chan,
version and flags 0, layout tag, 2 reserved words). afconvert writes the
bare 24 bytes.
| Offset | Size | Name | Description |
|---|---|---|---|
| 0 | 4 | frameLength | frames in a full packet, 4,096 |
| 4 | 1 | compatibleVersion | 0 |
| 5 | 1 | bitDepth | 16, 20, 24 or 32 |
| 6 | 1 | pb | Rice parameter, 40 (0x28) |
| 7 | 1 | mb | 10 |
| 8 | 1 | kb | 14 |
| 9 | 1 | numChannels | 1 to 8 |
| 10 | 2 | maxRun | 255 |
| 12 | 4 | maxFrameBytes | the largest packet in bytes |
| 16 | 4 | avgBitRate | bit/s |
| 20 | 4 | sampleRate | Hz |
Example from afconvert: 00 00 10 00 | 00 | 10 | 28 0A 0E | 02 | 00 FF
| 00 00 06 09 | 00 01 F8 B7 | 00 00 AC 44: 4,096 frames, 16-bit, stereo, largest
packet 1,545 bytes, 129,207 bit/s, 44,100 Hz.
FLAC
An MP4 dfLa box: size (u32), dfLa, version and flags (u32, 0),
then FLAC metadata blocks as in a FLAC file: a header byte (bit 7 last block, bits 0 to
6 type), a 24-bit length, the block. The first block is STREAMINFO (34 bytes: minimum
and maximum block size u16, minimum and maximum frame size u24, then 20 bits sample rate,
3 bits channels less one, 5 bits bits per sample less one, 36 bits sample count, and the
MD5 of the audio). Each packet in the data chunk is one FLAC frame; a
decoder puts fLaC, the metadata blocks and the frames together as a FLAC
stream.
Example: 00 00 00 32 64 66 4C 61 00 00 00 00
80 00 00 22 12 00 12 00 | 00 03 8D | 00 06 2A | 0A C4 42 F0 00 00 AC 44
| MD5 (16 bytes): a 50-byte box, one last block of type 0 and 34 bytes, 4,608-frame
blocks, 44,100 Hz, 2 channels, 16 bits, 44,100 samples.
Opus
Apple does not describe the cookie. Its Opus decoder (ACOpusDecoder::ParseMagicCookie in
AudioCodecs.component, read by disassembly, saved under research/caf/dsc/dis) takes two layouts,
tried in this order:
- An OpusHead (RFC 7845 section 5.1), when the cookie starts with the eight characters
OpusHeadand has a version of 1 to 15. This is the cookie of a file with more than two channels (with achanchunk); the decoder takes a header of 19 bytes for mapping family 0 (one or two channels) or 21 plus the channel count for family 1. Fields, in order: signature (8 bytes), version (u8, 1), channel count (u8), pre-skip (u16 little-endian: samples at 48 kHz to drop), input sample rate (u32 little-endian, informative), output gain (i16 little-endian, Q7.8 dB), mapping family (u8), and for families other than 0 the stream count (u8), the coupled stream count (u8) and one mapping byte for each channel (an index below 2 × coupled picks the left or right channel of a coupled stream, higher indexes pick a mono stream, 255 is silent). Family 1 puts the channels in the Vorbis order: 3 channels L C R; 4 quadraphonic; 5 L C R Ls Rs; 6 L C R Ls Rs LFE; 7 and 8 with side channels. Everything is in little-endian byte order, unlike every other number in a CAF. A 5.1 file written with ffmpeg’s libopus (4 streams, 2 coupled) and given this cookie decodes in Apple’safconvertto the same six channels as in the viewer, to 80 dB. - 28 bytes of seven big-endian 32-bit numbers, the form
afconvertwrites for mono and stereo. The decoder accepts the first only if it is 2048, 2049 or 2051, the second only if it is 8,000, 12,000, 16,000, 24,000 or 48,000, the third only up to 5,760, and the fifth only if it is in the decoder’s list of channel counts; the meaning below is from the constants libopus uses, from 513 files and from those checks:
| Offset | Value seen | Meaning |
|---|---|---|
| 0 | 0x800 (2048) | the encoder application: libopus’s OPUS_APPLICATION_VOIP is 2048, AUDIO is 2049, RESTRICTED_LOWDELAY 2051 |
| 4 | 48,000 or 24,000 | the sample rate, equal to mSampleRate |
| 8 | 960 or 480 | samples in a packet, equal to mFramesPerPacket |
| 12 | 0xFFFFFC18 (−1000) | libopus’s OPUS_AUTO as the bit rate |
| 16 | 1 or 2 | the number of channels |
| 20, 24 | 0, 0 | zero in every file seen |
Packets are plain Opus packets (RFC 6716), one to a CAF packet, with the packet table giving each size. Opus always decodes at 48,000 Hz; a file of 24,000 Hz means the audio is meant for that rate, and the pre-skip of 312 frames at 48,000 Hz is the packet table’s priming. The explorer decodes at 48,000 Hz and, for 24,000 Hz, drops every second sample after a low-pass filter.
iLBC
8 bytes: the frame size in samples (0xA0 = 160, the 20 ms mode of RFC
3951, 38-byte frames; 240 is the 30 ms mode, 50-byte frames) and a word of 0. Described
by Apple nowhere; both modes were written by afconvert (15,200 bit/s gives 160 frames and
38 bytes a packet, 13,333 bit/s 240 frames and 50 bytes) and the cookie is the same two words in each. The
second word is 0 in both, and what it would hold is not known: the cookie’s layout is the frame size and
that word.
Vorbis
Apple’s Vorbis decoder (ACVorbisDecoder::SetMagicCookie, calling VorbisHeader::Deserialize; read by
disassembly) takes the three Vorbis header packets in one of three layouts, told by the first byte:
| First byte | Layout |
|---|---|
02 | the Xiph form (as in a Matroska CodecPrivate): 02, the size of the first and of the second header each in 255-lacing (bytes of 255 add up until a byte below 255), then the identification, comment and setup headers; the third takes the rest |
00 | a big-endian 16-bit size before each of the three headers (the identification header is 30 bytes, so the cookie starts 00 1E) |
1E | a little-endian 16-bit size before each (starts 1E 00) |
Each header is a Vorbis I header packet (Xiph, Vorbis I specification sections 4.2 and 5): the packet type (1 identification, 3 comment,
5 setup), the six characters vorbis, then for the identification header the version (u32, 0), channels
(u8), sample rate (u32), the three bit rate hints (i32 each), the two block sizes as 4-bit exponents (blocksize_0 in the low nibble) and the framing
bit; for the comment header the vendor string and the user comments, each a u32 length and UTF-8 text; and for the
setup header the codebooks, floors, residues, mappings and modes. All numbers are little-endian. Each CAF packet is one
Vorbis audio packet, with the packet table giving each packet’s size and its number of frames
(a quarter of the previous and of this block size, none for the first). The three layouts were checked by building
CAFs from an ffmpeg Vorbis file in each: Apple’s afconvert decodes all three to the same samples, which agree with
ffmpeg’s, and the explorer’s Vorbis decoder agrees with both to 74 and 80 dB.
The AudioSpecificConfig, field by field
ISO/IEC 14496-3 (clause 1.6.2.1 and 4.4.1) lays it out as bits, most significant first. The explorer lists every field of the cookies it reads, with its bit range.
| Field | Bits | Meaning |
|---|---|---|
audioObjectType | 5 | 1 AAC Main, 2 LC, 3 SSR, 4 LTP, 5 SBR, 6 scalable, 7 TwinVQ, 17 ER AAC LC, 19 ER LTP, 20 ER scalable, 22 ER BSAC, 23 ER AAC LD, 29 PS, 39 ER AAC ELD, 42 USAC; 31 means 32 plus the next 6 bits |
samplingFrequencyIndex | 4 | 0 to 12: 96,000, 88,200, 64,000, 48,000, 44,100, 32,000, 24,000, 22,050, 16,000, 12,000, 11,025, 8,000, 7,350 Hz; 15: a 24-bit rate follows |
channelConfiguration | 4 | 0: set by a program config element in the stream; 1 mono; 2 stereo; 3 C L R; 4 C L R Cs; 5 C L R Ls Rs; 6 C L R Ls Rs LFE; 7 C Lc Rc L R Ls Rs LFE |
| for object types 5 and 29 | an extensionSamplingFrequencyIndex (4 bits, 15: 24-bit rate follows) and then the core audioObjectType again (5 bits; 22 is followed by a 4-bit extensionChannelConfiguration) | |
| GASpecificConfig (types 1 to 4, 6, 7, 17, 19 to 27) | frameLengthFlag (1 bit: 1,024 frames, or 960 when set), dependsOnCoreCoder (1; if set a 14-bit coreCoderDelay), extensionFlag (1); a program_config_element when the channel configuration is 0; layerNr (3 bits) for types 6 and 20; when the extension flag is set: numOfSubFrame (5) and layer_length (11) for type 22, three resilience flags for 17, 19, 20 and 23, then extensionFlag3 (1); epConfig (2 bits) for types of 17 and above | |
| ELDSpecificConfig (type 39) | frameLengthFlag (1: 480 frames, 0: 512), three resilience flags, ldSbrPresentFlag (1; if set, ldSbrSamplingRate and ldSbrCrcFlag and an SBR header), then extension types of 4 bits to a terminator | |
| UsacConfig (type 42) | usacSamplingFrequencyIndex (5 bits: a table of 28 rates, 31 means a 24-bit rate follows), coreSbrFrameLengthIndex (3: 768 or 1,024 core frames with or without SBR at 8:3, 2:1 or 4:1), channelConfigurationIndex (5; 0 means each channel is configured in UsacChannelConfig), then the decoder configuration. The explorer reads these first fields only | |
| backward-compatible extension | 11 + … | after the GA config: sync word 0x2B7, extensionAudioObjectType (5 bits); for 5 (SBR): sbrPresentFlag (1), extensionSamplingFrequencyIndex (4 or 28 bits) and, for parametric stereo, sync word 0x548 and psPresentFlag (1); for 22: sbrPresentFlag, the rate and a 4-bit extensionChannelConfiguration |
program_config_element | element_instance_tag (4), object_type (2), sampling_frequency_index (4), the numbers of front, side and back channel elements (4 each), LFE (2), associated data (3) and coupling channel (4) elements, three mixdown presence flags (mono: 1 + 4 bits; stereo: 1 + 4; matrix: 1 + 2 + 1), then for each front, side and back element a channel-pair flag and a 4-bit tag, LFE and data tags (4 bits each), coupling elements (1 + 4), byte alignment, and a comment of an 8-bit length and its bytes |
The HE-AAC cookie above (13 90 56 E5 A0) is AAC LC (2), index 7
(22,050 Hz), 2 channels, the 3 GA bits 0, then 0x2B7, type 5, SBR present,
index 4 (44,100 Hz).
Cookies of the other codecs
- QDesign 2 (
QDM2) and QDesign Music (QDMC): FFmpeg’s decoder (libavcodec/qdm2.c) reads the QuickTime sound description’s extra data, which a CAF carries as the cookie: afrmaatom namingQDM2, then aQDCAatom of 32-bit big-endian numbers: the atom size, the tag, an unknown number (1), channels, sample rate, bit rate, the group size (block size, 4,096 in its example), the FFT size (frame size per channel, 256) and the checksum (packet) size (1,300). The FFT size must be a power of two from 64 to 256 and the checksum size more than 1 and less than 228. - MACE 3:1 and 6:1: no cookie is needed: each packet is 2 bytes (3:1) or 1 byte (6:1) a channel and holds 6 frames. FFmpeg’s CAF demuxer treats them as ordinary packets.
- AMR (
samr,sawb): FFmpeg’s CAF demuxer passes the cookie on as it is; the packets are frames in the storage layout of 3GPP TS 26.101 (a header byte with the frame type, then the speech bits). - AC-3, E-AC-3, MPEG audio, µ-law, A-law, IMA4, PCM, GSM, IMA ADPCM: no cookie in the files seen; each packet is a whole sync frame, an MPEG audio frame, or a block.
- CELP, HVXC, TwinVQ, Spatial Audio, USAC: not seen in any file. FFmpeg’s CAF
demuxer would pass whatever cookie there is on as raw extra data; the MPEG-4
formats are expected to carry the
esdscontents as AAC does, but that is not confirmed by a file or a source.
APAC
A dapa MP4-style box (124 bytes in the file made by afconvert:
size, dapa, then 116 bytes). Apple does not publish the contents.
strg: strings
Named strings that other chunks refer to by ID.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mNumEntries | the number of strings |
| 4 | 12 each | record | mStringsIDs | an ID and offset for each string, below |
| … | … | bytes | mStrings | the strings, each null-terminated UTF-8 |
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mStringID | the ID; 0 is best avoided |
| 4 | 8 | s64 | mStringStartByteOffset | its offset from the first byte after the last ID record |
info: information
Key-value text. The structure is the number of entries, as a u32, followed by each key and
then its value, all null-terminated UTF-8 strings.
| Key | Value |
|---|---|
tempo | tempo |
key signature | key |
time signature | time signature |
artist | artist |
album | album |
track number | track number |
year | year |
composer | composer |
lyricist | lyricist |
genre | genre |
title | title |
recorded date | date |
comments | comments |
copyright | copyright |
source encoder | source encoder |
encoding application | encoding application |
nominal bit rate | nominal bit rate |
channel layout | channel layout |
approximate duration in seconds | not in the specification; written by Apple’s afconvert (for example 0.975) |
source bit depth | not in the specification; written by Apple’s afconvert: I16 for 16-bit integer source audio |
ISRC | not in the specification; kAFInfoDictionary_ISRC in the SDK’s AudioFile.h: the International Standard Recording Code (upper-case, so it is not one of the reserved lower-case keys) |
subtitle | not in the specification; kAFInfoDictionary_SubTitle in AudioFile.h |
encoding application | Amadeus Pro writes Amadeus Pro in a chunk that also has a zero pad byte, below |
copyright, comments, artist | Sound Ideas’ Final Cut Pro sound effects write all three, with the Apple Loops tags below |
- Lower-case keys are reserved. An application’s own keys need at least one upper-case letter.
- A key ending in
datehas a time-of-day value in ISO 8601, in UTC. - A key starting with a full stop is not displayed, but should be kept.
- Each key appears once. Several values are separated by commas.
- Where a MIDI chunk conflicts with these values, the MIDI chunk wins.
inst: instrument
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | f32 | mBaseNote | the MIDI note at which the sound plays unchanged: 60 is middle C, and the fraction is a pitch offset |
| 4 | 1 | u8 | mMIDILowNote | lowest note, 0 to 127 |
| 5 | 1 | u8 | mMIDIHighNote | highest note, 0 to 127 |
| 6 | 1 | u8 | mMIDILowVelocity | lowest velocity, 0 to 127 |
| 7 | 1 | u8 | mMIDIHighVelocity | highest velocity, 0 to 127 |
| 8 | 4 | f32 | mdBGain | gain in decibels; 0 is unchanged |
| 12 | 4 | u32 | mStartRegionID | the region played at the start |
| 16 | 4 | u32 | mSustainRegionID | the sustain region |
| 20 | 4 | u32 | mReleaseRegionID | the release region |
| 24 | 4 | u32 | mInstrumentID | the ID of its name in the strings chunk |
midi: MIDI data
A Standard MIDI File. It may carry tempo, key and time signature, or a MIDI version of
the audio. Its values override those in info. The explorer reads it to
its events: the header chunk MThd (length 6, format 0, 1 or 2, number of
tracks, a division that is ticks to a quarter note, or SMPTE frames a second and ticks a
frame when bit 15 is set), and each MTrk track chunk (a length, then
events). An event is a delta time in ticks (7 bits a byte, the top bit set while more
follow, at most 4 bytes), a status byte (left out when it repeats the last channel
message’s, “running status”) and its data: channel messages 80 to
EF (note off and on, key pressure, control change, program change, channel
pressure, pitch bend: one or two data bytes of 0 to 127), meta events FF
(a type, a length and data: sequence number, text, copyright, track name, instrument,
lyric, marker, cue point, channel prefix, port, end of track 2F, tempo
51 in microseconds a quarter note, SMPTE offset 54, time
signature 58, key signature 59, sequencer-specific
7F) and system exclusive messages F0 and F7 with a
length. The explorer shows tempo, time and key signature in words, and marks a track
with no end-of-track event or a system message that a file may not hold.
edct: edit comments
Laid out like info: the number of entries, then pairs of strings. Each key
is a time of day in ISO 8601, in UTC, and each value a UTF-8 comment.
ovvw: overview
A reduced waveform for drawing the sound quickly. An overview may be made for several
resolutions, so a file may have more than one. Every entry covers
mNumFramesPerOVWSample frames and holds, for each channel in file order,
the smallest and the largest sample (two big-endian 16-bit signed numbers). The explorer
shows every entry’s values and marks an overview whose edit count differs from the
audio’s.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mEditCount | matches the data chunk’s edit count, so a stale overview can be detected |
| 4 | 4 | u32 | mNumFramesPerOVWSample | the number of audio frames per overview entry |
| 8 | 4 each | record | mData | one minimum and one maximum s16 per channel per entry |
peak: peak
The size of the chunk is 4 + 12 × channels.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mEditCount | matches the data chunk’s edit count |
| 4 | 12 each | record | mPeaks | one per channel, below |
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | f32 | mValue | the peak, normalised to −1.0 to 1.0 |
| 4 | 8 | u64 | mFrameNumber | where it occurs, from 0 |
umid: unique material identifier
Exactly 64 bytes (CAFUMIDChunk, UInt8 mBytes[64] in the SDK’s CAFFile.h), an
Extended UMID of SMPTE ST 330, and at most one in a file. The first 32 bytes are the Basic UMID: a 12-byte
universal label, a length byte, a 3-byte instance number and a 16-byte material number. The
second 32 are the source pack: when and where the material unit was made and by whom. Unused components
of the source pack are all zero. The layout below is that of SMPTE ST 330:2022 (read in full from
pub.smpte.org/pub/st330/st330-2022.pdf).
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 12 | universal label | Table 1: 06 0A 2B 34 01 01 01 05 01 01 (object identifier, 12-byte label, ISO and SMPTE registered, dictionaries, metadata dictionaries, ST 335, version 5, identifiers and locators, globally unique identifiers), then byte 10 (0-based), the material type (Table 2, below), and byte 11, the method that made the material number (high nibble, 0 to 7, Table 3) and the one that made the instance number (low nibble, Table 4) |
| 12 | 1 | length | the bytes that follow: 0x13 (19 = instance 3 + material 16) for a Basic UMID, 0x33 (51 = those and the 32-byte source pack) for an Extended UMID |
| 13 | 3 | instance number | 0 for the original material, non-zero for a copy or derivation |
| 16 | 16 | material number | non-zero, globally unique for each item of material; made by one of the methods of Annex A |
| 32 | 8 | date stamp and unit count | 6.4.2.2: see below |
| 40 | 4 | altitude | 6.4.3.2: see below |
| 44 | 4 | longitude | 6.4.3.3: see below |
| 48 | 4 | latitude | 6.4.3.4: see below |
| 52 | 4 | country | an ISO 3166-1 code in characters 20h to 7Eh, padded with spaces (3-letter codes preferred), or all zero |
| 56 | 4 | organisation | local to the country; characters 20h to 7Eh padded with spaces, or all zero; a first character “~” (7Eh) makes organisation and user together an 8-byte freelance operator code |
| 60 | 4 | user | local to the organisation: a department, person or device; all zero if the organisation is zero |
Material types (byte 10): 05 single picture component, 06 several picture components in one container, 08 single audio component, 09 several audio components in one container, 0B single auxiliary (data) component, 0C several auxiliary components, 0D a mixed group of components in one container, 0F not identified; 01 to 04 (picture, audio, data, other) are deprecated. Material number methods (high nibble of byte 11): 0 none defined, 1 SMPTE (an 8-byte time snap, a 2-byte random number and a 6-byte IEEE node identifier), 2 UUID/UL, 3 masked, 4 IEEE 1394 network, 5 hashed, 6 reserved, 7 fixed. Instance number methods (low nibble): 0 none, 1 local registration, 2 24-bit PRS generator, 3 copy number and 16-bit PRS generator, 4 copy number and local registration, 5 to E reserved, F live stream.
The date stamp and unit count
All numbers in the source pack are least significant byte first (6.1). The 8 bytes are:
| Bytes | Field | Description |
|---|---|---|
| 0 to 3 | unit count rate and unit count value | bits 0 to 5 of the first byte are the unit count rate (Table 5); the other 26 bits (a0 to a25, from bit 6 of the first byte) are the number of units since midnight UTC |
| 4 to 6 | Modified Julian Date | six decimal digits (BCD), the least significant pair first: units and tens in byte 4, hundreds and thousands in byte 5, ten-thousands and hundred-thousands in byte 6 |
| 7 | time-zone code and flags | bits 0 to 5: the time-zone code (Table 7, read as two hexadecimal digits; for descriptive use only, the count always starts at midnight UTC); bit 6: reserved, always 0; bit 7: MJD flag, always 1 |
Unit count rates (Table 5, value of bits 0 to 5 in decimal, then the rate in Hz): 0 (the default) 48000/64 = 750, 1 32000/64 = 500, 2 24, 3 24/1.001, 4 25, 6 30, 7 30/1.001, 8 48, 9 48/1.001, 10 50, 12 60, 13 60/1.001, 14 72, 16 75, 18 90, 20 96, 22 100, 24 120, 25 120/1.001, 26 144, 28 160, 30 165, 32 180, 34 200, 36 240, 37 240/1.001, 38 300, 49 1, 60 44100/64 (about 689), 61 44100/64.064 (about 688), 63 unspecified; every other value is reserved. The time of day is the count divided by the rate. Time-zone codes (Table 7): 00 is UTC, 01 to 09, 10 and 11 are UTC−1 to UTC−11, 12 is UTC−12, 13 is UTC+13, 14 to 25 are UTC+12 down to UTC+1; the half-hour offsets are 0A to 0F (UTC−0:30 to −5:30), 1A to 1F (−6:30 to −11:30), 2A to 2F (+11:30 to +6:30) and 3A to 3F (+5:30 to +0:30); 32 is UTC+12:45; 26 and 27 and 33 to 37 are reserved, 28 to 31 deprecated, 38 a user-defined offset and 39 unknown.
The spatial coordinates
Altitude, longitude and latitude are 4 bytes each, little-endian, every nibble one decimal digit (nibble 0 is the low half of the first byte, nibble 7 the high half of the fourth); the reference system is WGS-84 (6.4.3). All 12 bytes are zero when unused.
| Part | Coding |
|---|---|
| altitude | If nibbles 0 to 7 are all digits: metres from the centre of the earth. If nibble 7 is A to F: metres relative to the local geoid; A, B, C are positive and D, E, F negative, and A/D mean the position is that of the sensor device (camera or microphone), B/E the recording device and C/F the target object (Table 8). Nibble 6 then tells how the position was found (Table 9): 0 entered by hand, 1 GPS result not valid, 2 supportive apparatus only, 4 two satellites, 6 two satellites with apparatus, 8 three satellites, A three satellites with apparatus, C four or more, E four or more with apparatus (nibble 5 and the lower nibbles are the altitude, up to ±999,999 m); 9, B, D, F are the same with three or more satellites and nibble 5 holding the PDOP (altitude up to ±99,999 m); 3, 5 and 7 give the camera’s shooting direction instead: 3 azimuth (nibble 5, 16 compass points of 22.5°, Table 10) and elevation (the top three bits of nibble 4, Table 11), 5 azimuth only, 7 omnidirectional; the altitude is then the low bit of nibble 4 and nibbles 3 to 0, up to ±19,999 m |
| longitude | Nibble 7: 0 west and a hundreds digit of 0, 1 west and 1, E east and 0, F east and 1 (Table 12); nibbles 6 and 5 the tens and units of the degrees; nibbles 4 to 0 five decimal places |
| latitude | Nibble 7: 0 north, F south (Table 13); nibbles 6 and 5 the degrees; nibbles 4 to 0 five decimal places |
The viewer decodes every field above, checks the digits, flags and reserved values against the standard, and lists a problem where one does not follow it. The pictures of the standard’s Figures 2 and 3 were read from the PDF’s rendered pages (the bit order of the date stamp and the nibble numbering).
Source: SMPTE ST 330:2022, Unique Material Identifier (UMID), sections 5, 6.1 to 6.4 and tables 1 to 13 (the free PDF on pub.smpte.org); the size, 64 bytes, is also CAFFile.h’s CAFUMIDChunk.
uuid: user-defined
Lets an application store its own data. The data starts with a 16-byte UUID, and the
chunk’s size counts it. A parser ignores a UUID it does not know. If the data depends on
the audio, the application should store the data chunk’s edit count after
the UUID.
free: free space
Reserved space. Its contents are ignored. Apple’s tools write one after the header
chunks, of about 4,000 bytes, so that a tool can add chunks without moving the audio
(the free chunk in most files on this Mac is 3,700 to 4,016 bytes, or 20
or 28,000 bytes in the Final Cut Pro sound effects).
uuid chunks seen on a Mac
| UUID | Where | Contents |
|---|---|---|
29819273-B5BF-4AEF-B78D-62D1EF90BB2C | Apple Loops and Final Cut Pro sound effects (1,337 files) | laid out like an info chunk: a u32 count of entries, then key and value strings, each null-terminated. Keys named by the open reader: beat count (the number of beats in the loop), key signature (a note such as C#), key type (major or minor), time signature (4/4), category (Horn/Wind), subcategory, genre (Orchestral) and descriptors (a comma-separated list); files here also have theme and others, read as ordinary strings (for example category = Sound Effect, subcategory = Motions & Transitions) |
0352811B-9D5D-42E1-882D-6AF61A6B330C | the same files, the chunk after the one above (1,337 files) | transient markers (slice points). After the UUID: a 20-byte header, then 12 bytes for each transient. Header: 4 bytes not used (0), a u16 version (1), 2 bytes not used (0), a u16 transientDetectionPercentage (0x32, 50), a u16 forceDivisionValue (0x10, 16) and a u64 count of transients. Each transient: a u16 transientType (1), 2 bytes not used (0) and a u64 frame position. All numbers are big-endian. Most Apple Loops on this Mac have a count of 0 (the 20 bytes 00000000 00010000 00320010 00000000 00000000); Logic’s own sample Prismatica Funk Guitar 02.caf has 60 transients (a chunk size of 756 bytes: the 16-byte UUID, the 20-byte header and 60 × 12 = 720 bytes of transients). |
CEE5B7CA-83E4-472C-9764-4CE0C35CF05C | Apple Loops (no file here has it) | the silence chunk: the UUID that MAFiles.framework (GarageBand and Logic) names cafSilenceUUIDChunkID. The framework keeps its data as plain bytes; no layout is given by its code, and no file on this Mac has the chunk. |
The two UUIDs are not in the CAF specification or the SDK headers, and Apple does not document the
chunks. The layouts above are those of the open-source Apple Loops reader
apple-loops-meta-reader (github.com/jhorology/apple-loops-meta-reader, read in full,
including how it works out the tempo) and agree with the files on this Mac. What no source gives is the
meaning of the 16 header bytes before the transient count and of the 32-bit word in each transient.
Chunks the specification does not define
A reader skips a chunk type it does not know, by its size. These are seen on this Mac.
ldsc: format list
Not in the specification, but defined in the SDK’s CAFFile.h (kCAF_FormatListID,
CAFAudioFormatListItem): for data formats like AAC SBR that can be decompressed to several
formats, a list of 36-byte items, each a 32-byte audio description (as in desc) and a 4-byte
channel layout tag (mChannelLayoutTag), “ordered from best to worst by number of channels and
sample rate in that order”. Apple’s encoder writes it for HE-AAC (afconvert -d aach and
aacp). Example, 72 bytes:
40E58880 00000000 (44,100 Hz) 61616368 (aach)
00000000 00000000 00000800 00000002 00000000 (flags 0, packets vary,
2,048 frames, 2 channels, 0 bits) 00650002 (Stereo), then
40D58880 00000000 (22,050 Hz) 61616320 (aac )
… 1,024 frames … 00650002. It follows desc.
iXML: iXML metadata
The SDK’s CAFFile.h lists the chunk type iXML (kCAF_iXMLChunkID)
and gives no layout. The chunk holds the metadata of the iXML specification (Gallery UK, revision 3.01,
read from www.gallery.co.uk/ixml/, whose pages say that iXML can also be included in
file types other than WAVE): “a raw text block using XML format layout”, with no identification at its
head. The text is single-byte, usually UTF-8, or two-byte Unicode; a reader may look for
<?xml in either form. The root element is BWFXML, and every element is optional:
a reader must not assume that any is present, and must expect elements the specification does not
list. A writer may pad the chunk with white space between fields so that it can grow; the
specification asks for an even byte count, with a space added at the end if it is odd. Inside values, the characters
<, > and & are written
<, > and &.
The explorer shows every element as a node with its bytes, text and a note from the specification,
an element with child elements has its start tag, content and end tag as children, and it lists a
problem for a wrong or missing end tag, a root other than BWFXML, a
TRUE/FALSE field with another value and a version that is not x.y. The elements:
| Element | Meaning |
|---|---|
IXML_VERSION | the version of the specification, x.y, for example 1.51 |
PROJECT, SCENE, TAPE, TAKE | the project name, the scene or slate, the sound roll (a group of recordings, changed at least once in 24 hours) and the take number |
TAKE_TYPE | (iXML 2.0) a comma-separated list from DEFAULT, NO_GOOD, FALSE_START, WILD_TRACK, PICKUP, REHEARSAL, ANNOUNCEMENT, SOUND_GUIDE; replaces the deprecated NO_GOOD, FALSE_START and WILD_TRACK elements (TRUE or FALSE) |
CIRCLED, FILE_UID, UBITS, NOTE | a circled take (TRUE or FALSE), a unique number for the file, the user bits, a free note |
SYNC_POINT_LIST | SYNC_POINT_COUNT, then SYNC_POINT objects with SYNC_POINT_TYPE (RELATIVE or ABSOLUTE), SYNC_POINT_FUNCTION (PRE_RECORD_SAMPLECOUNT, SLATE_GENERIC, HEAD_SLATE, TAIL_SLATE, MARKER_GENERIC, MARKER_AUTOPLAY, MARKER_AUTOPLAYSTOP, MARKER_AUTOPLAYLOOP, GROUP_OFFSET), SYNC_POINT_COMMENT, SYNC_POINT_LOW and SYNC_POINT_HIGH (the 64-bit sample count in two halves) and SYNC_POINT_EVENT_DURATION (0 for a marker) |
SPEED | NOTE, MASTER_SPEED and CURRENT_SPEED (ratios such as 24/1 or 30000/1001), TIMECODE_RATE, TIMECODE_FLAG (NDF or DF), and copies of the file’s FILE_SAMPLE_RATE, AUDIO_BIT_DEPTH, DIGITIZER_SAMPLE_RATE, TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI and _LO and TIMESTAMP_SAMPLE_RATE |
LOUDNESS | LOUDNESS_VALUE (LUFS), LOUDNESS_RANGE (LU), MAX_TRUE_PEAK_LEVEL (dBTP), MAX_MOMENTARY_LOUDNESS and MAX_SHORT_TERM_LOUDNESS (LUFS) |
HISTORY | ORIGINAL_FILENAME, PARENT_FILENAME, PARENT_UID |
FILE_SET | TOTAL_FILES, FAMILY_UID, FAMILY_NAME, FILE_SET_INDEX, and for sets whose files do not start together FILE_SET_START_TIME_HI and _LO |
TRACK_LIST | TRACK_COUNT, then TRACK objects with CHANNEL_INDEX (the recorder’s input, from 1), INTERLEAVE_INDEX (the place in the file, from 1), NAME and FUNCTION (for example LEFT, M-MID_SIDE, L-5.1, ACN0-FOA) |
PRE_RECORD_SAMPLECOUNT | deprecated: use the sync point of that name |
BEXT | a copy of the Broadcast Wave bext chunk for other file types: BWF_DESCRIPTION, BWF_ORIGINATOR, BWF_ORIGINATOR_REFERENCE, BWF_ORIGINATION_DATE, BWF_ORIGINATION_TIME, BWF_TIME_REFERENCE_LOW and _HIGH, BWF_VERSION, BWF_UMID, BWF_RESERVED, BWF_CODING_HISTORY and the five BWF_ loudness values |
USER | free text, or from iXML 2.0 the AFSI fields FULL_TITLE, DIRECTOR_NAME, PRODUCTION_NAME, _ADDRESS, _EMAIL, _PHONE, _NOTE, SOUND_MIXER_NAME, _ADDRESS, _EMAIL, _PHONE, _NOTE, AUDIO_RECORDER_MODEL, _SERIAL_NUMBER, _FIRMWARE |
LOCATION | LOCATION_NAME, LOCATION_GPS (latitude, longitude in decimal degrees), LOCATION_ALTITUDE, LOCATION_TYPE (INT, EXT), LOCATION_TIME (SUNRISE, MORNING, MIDDAY, DAY, AFTERNOON, EVENING, SUNSET, NIGHT) |
Track FUNCTION values in the specification’s dictionary include the stereo, mid-side, X/Y, DMS, LCR, LCRS, 5.1 and 7.1 families, a generic surround and height set (L-GENERIC to Bsr-GENERIC), the Soundfield B-format W-SOUNDFIELD to Z-SOUNDFIELD, ambisonic channels ACN0-FOA to ACN3-FOA, ACN0-HOA2 to ACN8-HOA2 and ACN0-HOA3 to ACN15-HOA3, and VIDEO. The specification’s further pages (the QuickTime and NDI uses, the schema and extending iXML) are not CAF matters. Source: the iXML specification 3.01, pages “The iXML Chunk”, “Individual Object Details” and the three dictionaries (research/caf/ixml/).
ID3 : ID3v2 tag
Amadeus Pro writes an ID3v2 tag as the data of a chunk whose type is ID3
(with a trailing space). The size is the tag’s size, and the tag is shown as in an MP3
file (frames, text, pictures). It writes a zero byte after a chunk of odd size, which
CAF does not allow: a reader that follows the sizes sees the next chunk type start
with a zero. About 40 files on this Mac have it: Amadeus Pro’s files hold mark
(empty or with one marker), CLST (4 bytes), strg
(4 bytes) and ID3 chunks. The explorer takes the pad byte as a node of its own and says so.
Amadeus Pro 3 (downloaded from hairersoft.com into research/caf/amadeus and disassembled, never run) writes
the chunks in this order in -[HSAVCAFWriter writeMetadataTo:]: info, mark,
CLST, strg, ID3 .
CLST: marker colours
Written by Amadeus Pro (the code is at address 0x1000963cc of its arm64 binary, -[HSAVCAFWriter writeMetadataTo:],
and the reader in -[HSAVCAFReader readMetadata:fromURL:]): a u32 number of markers (the same as in the
mark chunk), then a u16 colour index (Amadeus Pro’s colorIndex of the marker) for each marker, in the
order of the mark chunk. A file with no markers holds the 4 bytes 00000000, which is what the files on
this Mac have. The meaning of the colour numbers is Amadeus Pro’s own palette and is not defined by the code that writes them.
ResU: tempo analysis result
Not written by Amadeus Pro: one Apple file on this Mac has it (Indentation.caf in ScreenReader.framework). The
data is a zlib stream (RFC 1950: 78 9C …) that inflates to UTF-8 JSON, the result of Apple’s tempo and beat analysis (the
flag names say Logic: ResultWasCreatedFromLogicTempoMap). Keys seen: version (1), initial and
rec_ctx, each with version, offset, duration (seconds), db_time,
relevant_start_time, relevant_end_time, mtr_end, creationTime, modificationTime,
savedTime, MusicDetectionWasPerformed, ArrangeTapsWereUsedInAnalysis,
ResultWasCreatedFromLogicTempoMap, ResultWasCreatedFromLogicArrange, UserEdited and the lists
beats (t, conf, onset), Tempo (t, conf, tempo)
and time_signatures (t, conf, signature). The explorer inflates it and
summarises the duration, beats, tempo and signature.
Source: Apple, Core Audio Format Specification 1.0, sections Magic Cookie Chunk, Strings Chunk, MIDI Chunk, Overview Chunk, Peak Chunk, Edit Comments Chunk, Information Chunk, UMID Chunk, User-Defined Chunk and Free Chunk (Tables 2-14, 2-15 and 2-19 onward). Information-chunk keys marked as not in the specification are from AudioFile.h (kAFInfoDictionary_*) or from files written by Apple software, as said where they appear. The ldsc and iXML chunk types and the structure of ldsc are from CAFFile.h.