An AU file is six 32-bit big-endian header fields, an annotation and then the samples. The header and the samples are big-endian on every machine.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | au_magic | .snd: bytes 2E 73 6E 64 |
| 4 | 4 | u32 | au_offset | the byte offset of the audio data from the start of the file: the header plus the annotation |
| 8 | 4 | u32 | au_data_size | the length of the audio in bytes, or 0xFFFFFFFF when unknown |
| 12 | 4 | u32 | au_encoding | how the samples are stored; see Encodings |
| 16 | 4 | u32 | au_sample_rate | the sample rate in hertz: 8000, 11025, 22050, 44100 or 48000, for example |
| 20 | 4 | u32 | au_channels | the number of interleaved channels: 1 is mono and 2 stereo |
| 24 | au_offset − 24 | bytes | annotation | text or any other data, below |
au_offset | au_data_size | bytes | audio | the samples, in one contiguous run |
The field names are those of the au_filehdr structure in the Solaris
manual page. A file has one run of audio only.
Annotation
The bytes from offset 24 up to au_offset are the annotation. Its size is
fixed when the file is written, and it cannot grow later. It may hold text or any other
data. Text should end in a zero byte, but some older files do not, so a reader must use
au_offset to find the end rather than scan for a zero.
The format defines the annotation as at least 4 bytes long, making the minimum
au_offset 28. The older Sun form required its length to be a non-zero
multiple of 8. Not every writer keeps to this: libsndfile writes an offset of 24 and
no annotation, and readers should accept it. FFmpeg stores title, artist, album, track
and genre as key=value lines separated by a newline or a zero byte.
Most software ignores the annotation.
Audio data
Samples are interleaved by channel: for stereo, the first sample is the left channel and the second the right. Each sample uses the bytes its encoding needs, most significant byte first.
When au_data_size is 0xFFFFFFFF, the audio runs to the end of
the file: its length is the file’s length minus au_offset. A writer sets
this value when it does not know the length, as when writing to a pipe.
The little-endian form
A file starting dns. (64 6E 73 2E) is the same format with
its header and samples little-endian. libsndfile reads and writes this form; the
specifications listed here do not define it.
Example
A header for one second of mono 8-bit µ-law audio at 8,000 Hz, with an 8-byte annotation:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 0 | 2E 73 6E 64 | magic | .snd |
| 4 | 00 00 00 20 | au_offset | 32 |
| 8 | 00 00 1F 40 | au_data_size | 8,000 bytes |
| 12 | 00 00 00 01 | au_encoding | 1, µ-law |
| 16 | 00 00 1F 40 | au_sample_rate | 8,000 Hz |
| 20 | 00 00 00 01 | au_channels | 1 |
| 24 | 8 bytes | annotation | text, then zeros |
| 32 | 8,000 bytes | audio |