The chan chunk gives each channel a meaning. It is required when a file has
more than two channels and their order matters. Without one, a mono file is one channel
and a stereo file is left then right.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mChannelLayoutTag | the layout, below |
| 4 | 4 | u32 | mChannelBitmap | used with the bitmap tag |
| 8 | 4 | u32 | mNumberChannelDescriptions | the number of descriptions that follow |
| 12 | 20 each | record | mChannelDescriptions | used with the descriptions tag |
A channel description:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | mChannelLabel | a label |
| 4 | 4 | u32 | mChannelFlags | how to read the coordinates, below |
| 8 | 12 | f32[3] | mCoordinates | the speaker’s position, with label 100 |
| Flag | Constant |
|---|---|
| 0 | kCAFChannelFlags_AllOff |
| bit 0 | kCAFChannelFlags_RectangularCoordinates |
| bit 1 | kCAFChannelFlags_SphericalCoordinates |
| bit 2 | kCAFChannelFlags_Meters |
Channel bitmap
With the bitmap tag, each set bit in mChannelBitmap is one channel, in
order from the lowest bit up. The WAV column gives WAV’s name for the same speaker,
where Apple’s specification notes one.
| Bit | Constant (after kCAFChannelBit_) | WAV name |
|---|---|---|
| 0 | Left | |
| 1 | Right | |
| 2 | Center | |
| 3 | LFEScreen | |
| 4 | LeftSurround | Back Left |
| 5 | RightSurround | Back Right |
| 6 | LeftCenter | |
| 7 | RightCenter | |
| 8 | CenterSurround | Back Center |
| 9 | LeftSurroundDirect | Side Left |
| 10 | RightSurroundDirect | Side Right |
| 11 | TopCenterSurround | |
| 12 | VerticalHeightLeft | Top Front Left |
| 13 | VerticalHeightCenter | Top Front Center |
| 14 | VerticalHeightRight | Top Front Right |
| 15 | TopBackLeft | |
| 16 | TopBackCenter | |
| 17 | TopBackRight | |
| 18 to 20 | (none) | not defined |
| 21 | LeftTopMiddle | Xcode SDK |
| 22 | (none) | not defined; the SDK’s CenterTopMiddle is bit 11, TopCenterSurround |
| 23 | RightTopMiddle | Xcode SDK |
| 24 | LeftTopRear | Xcode SDK |
| 25 | CenterTopRear | Xcode SDK |
| 26 | RightTopRear | Xcode SDK |
The SDK also gives the height bits second names: LeftTopFront,
CenterTopFront and RightTopFront are bits 12, 13 and 14
(VerticalHeightLeft, …Center, …Right). Bits 18 to
20, 22 and 27 to 31 have no name; the explorer marks them.
Coordinates
With label 100 (UseCoordinates) a channel is placed by the three
numbers of mCoordinates, read as the flags say. Apple’s conventions
(the specification, and the same words in the SDK header):
| Flags | mCoordinates[0] | mCoordinates[1] | mCoordinates[2] |
|---|---|---|---|
| rectangular (bit 0) | left and right (kAudioChannelCoordinates_LeftRight): negative is left, positive is right | back and front (BackFront): negative is back, positive is front | down and up (DownUp): negative is below ground level, 0 is ground level, positive is above |
| spherical (bit 1) | azimuth in degrees (Azimuth): 0 is front centre, positive is right, negative is left | elevation in degrees (Elevation): +90 is the zenith, 0 is horizontal, −90 is the nadir | distance (Distance) |
Bit 2, kCAFChannelFlags_Meters, says what the units are: set, metres;
clear, relative to the unit cube (rectangular) or the unit sphere (spherical), with
the listener at the centre, the sphere’s radius 1 and the distance from the centre to
the middle of a side of the cube 1. The rectangular and spherical flags are mutually
exclusive; with no coordinate information, the flags and coordinates are 0. For a
channel that is not label 100 the coordinates are normally 0, and a channel’s label
takes precedence in the info chunk’s channel layout text
(the chan chunk always wins over it). The explorer shows each channel’s
coordinates and marks a position with flags that are neither rectangular nor
spherical.
Channel labels
| Value | Constant (after kCAFChannelLabel_) | Note |
|---|---|---|
0xFFFFFFFF | Unknown | |
| 0 | Unused | |
| 100 | UseCoordinates | the position is in mCoordinates |
| 1 | Left | |
| 2 | Right | |
| 3 | Center | |
| 4 | LFEScreen | |
| 5 | LeftSurround | WAV: Back Left |
| 6 | RightSurround | WAV: Back Right |
| 7 | LeftCenter | |
| 8 | RightCenter | |
| 9 | CenterSurround | WAV: Back Center, or plain Rear Surround |
| 10 | LeftSurroundDirect | WAV: Side Left |
| 11 | RightSurroundDirect | WAV: Side Right |
| 12 | TopCenterSurround | |
| 13 | VerticalHeightLeft | WAV: Top Front Left |
| 14 | VerticalHeightCenter | WAV: Top Front Center |
| 15 | VerticalHeightRight | WAV: Top Front Right |
| 16 | TopBackLeft | |
| 17 | TopBackCenter | |
| 18 | TopBackRight | |
| 33 | RearSurroundLeft | |
| 34 | RearSurroundRight | |
| 35 | LeftWide | |
| 36 | RightWide | |
| 37 | LFE2 | |
| 38 | LeftTotal | matrix encoded |
| 39 | RightTotal | matrix encoded |
| 40 | HearingImpaired | |
| 41 | Narration | |
| 42 | Mono | |
| 43 | DialogCentricMix | |
| 44 | CenterSurroundDirect | back centre, not diffuse |
| 45 | Haptic | Xcode SDK |
| 49 | LeftTopMiddle | Xcode SDK (the SDK also names 13, 14, 15 LeftTopFront, CenterTopFront, RightTopFront and 12 CenterTopMiddle) |
| 51 | RightTopMiddle | Xcode SDK |
| 52 | LeftTopRear | Xcode SDK |
| 53 | CenterTopRear | Xcode SDK |
| 54 | RightTopRear | Xcode SDK |
| 55 | LeftSideSurround | Xcode SDK |
| 56 | RightSideSurround | Xcode SDK |
| 57 | LeftBottom | Xcode SDK |
| 58 | RightBottom | Xcode SDK |
| 59 | CenterBottom | Xcode SDK |
| 60 | LeftTopSurround | Xcode SDK |
| 61 | RightTopSurround | Xcode SDK |
| 62 | LFE3 | Xcode SDK |
| 63 | LeftBackSurround | Xcode SDK |
| 64 | RightBackSurround | Xcode SDK |
| 65 | LeftEdgeOfScreen | Xcode SDK |
| 66 | RightEdgeOfScreen | Xcode SDK |
| 200 | Ambisonic_W | |
| 201 | Ambisonic_X | |
| 202 | Ambisonic_Y | |
| 203 | Ambisonic_Z | |
| 204 | MS_Mid | |
| 205 | MS_Side | |
| 206 | XY_X | |
| 207 | XY_Y | |
| 208 | BinauralLeft | Xcode SDK |
| 209 | BinauralRight | Xcode SDK |
| 301 | HeadphonesLeft | |
| 302 | HeadphonesRight | |
| 304 | ClickTrack | |
| 305 | ForeignLanguage | |
| 400 | Discrete | Xcode SDK: an unnamed discrete channel |
| 500 | HOA_ACN | Xcode SDK: a higher-order Ambisonics channel |
The Xcode SDK also defines labels as a base ORed with an index in the low 16 bits:
Discrete_n is (1 << 16) | n, HOA_ACN_n is
(2 << 16) | n, HOA_N3D_n is (3 << 16) | n
and Object is (4 << 16) with the object index. Labels
from 0xF0000000 to 0xFFFFFFFE are reserved for Apple’s
internal use.
The explorer shows these names, checks the tag’s channel count against the file’s, the bitmap’s set bits against it, and that a descriptions layout has one description for each channel.
Source: Apple, Core Audio Format Specification 1.0, section Channel Layout (tags 0 to 147, channel bitmap bits 0 to 17, label codes up to 305, channel flags); tags 148 and above, the bitmap bits above 17 and labels the specification does not list come from the Xcode SDK header CoreAudioBaseTypes.h (kAudioChannelLayoutTag_, kAudioChannelLabel_, kAudioChannelBit_), as stated where they appear. Every number and name above is compared with both texts by scripts/caf/spec-check.mjs.