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 (NeXT’s soundstruct.h: “the four bytes allocated are a
minimum”). Writers add a rule of their own on top: libSoX pads the header to a multiple of 4
by convention, and a comment in FFmpeg’s au.c says the specification requires a
multiple of 8 (no primary Sun source for that was found). Not every writer keeps to
either: 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.
Oracle’s au(4) page describes the information field as optional, while NeXT’s
soundstruct.h and the McGill notes give it the four-byte minimum above; readers that follow
au_offset handle both. Most software ignores the annotation.
The two rules belong to two families of writer. Sun’s own header au.h (Solaris, usr/src/head/audio/au.h)
declares the information field as optional (“4 bytes (min)” in the comment, with the structure ending at the
channel count), so a file made by Sun’s software may have an offset of 24 and nothing after the header. The IRIX
next(4) page, which Kaitai’s AU specification quotes, says a NeXT file needs the field of at least
4 bytes whereas a Sun file may have none, and warns against assuming the two headers are interchangeable.
Sun’s au.h also defines only encodings 1 to 8, 10 to 14, 18 to 21 and 23 to 27; the others come from NeXT’s header.
The explorer accepts both and flags an annotation shorter than 4 bytes only as a note.
What writers put in the annotation, by family:
- Plain text, usually one line, ended by a zero byte and padded with zeros: NeXT and Sun tools, and libSoX, which
writes its comments joined by newlines, a zero byte, and zeros up to a multiple of 4 bytes with a minimum of 4.
Files written by Apple’s
afconverthave an offset of 28 and four zero bytes. key=valuelines separated by a newline or a zero byte: what FFmpeg reads and writes. It keeps only the keystitle,artist,album,trackandgenre; the explorer shows every pair.- AFsp records: Peter Kabal’s AFsp package (McGill,
AFsetInfo) puts the identifierAFspstraight after the header, followed by information records, each a keyword ending in a colon and its text, ended by a zero byte, for exampleAFspdate:1981/02/11 23:03:34 UTC,database:…,speaker:…. Its standard records aredate:,program:,sample_rate:(when not an integer),loudspeakers:andbits_per_sample:; a writer may add its own. The last record has no zero byte when it ends atau_offset. The explorer lists each record as a row. - An IRCAM sound-file header (the “BICSF hybrid”): the Berkeley/IRCAM/CARL Sound File system’s header is the first
1,024 bytes of a file (see its Header and Codes pages): a magic number 107364 (
0x0001A364), a 4-byte float sample rate, a 4-byte channel count, a 4-byte packing mode (2 for 16-bit integers, 4 for 32-bit floats) and then, from byte 16, a chain of codes (BICSFsfheader.7andsfcodes.3). IRCAM’s ownsfheader.h(version 1.5, 1992) writes the magic as the bytes64 A3 MM 00, withMMthe machine that wrote the file (1 VAX, 2 Sun, 3 MIPS, 4 NeXT); Sun and NeXT write big-endian numbers, VAX and MIPS little-endian, and the explorer follows that. In the real hybrid file the explorer was checked on, the AU header hasau_offset1,024 and the IRCAM header starts at byte 28, four bytes into the annotation. Each code is a 2-byte code and a 2-byte size, the size counting those 4 bytes: 0 ends the chain, 1 is the maximum amplitude (four floats, four sample positions and a time tag in Unix seconds, 36 bytes of data), 2 is a comment (512 bytes in BICSF’s header). The numbers of the IRCAM header are big-endian in that file but its chain of codes is little-endian, so the explorer tries both orders. It lists the rate, channels, packing mode, maximum amplitude and comment as rows. - Nothing: libsndfile and Java’s
AuFileWriterwrite an offset of 24.
The sample rate field is an integer. NeXT’s soundstruct.h names four rates its hardware
plays directly (8012.8210513, 22050, 44100 and 11025 Hz); see
Encodings.
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 and libSoX read and write this form; the
specifications listed here do not define it.
DEC’s own workstations wrote it: Guido van Rossum’s Audio File Formats FAQ (1995) says DECstation 5000 systems use
“a variant of the NeXT format that uses little-endian encoding and has a different magic number (0x0064732E in
little-endian encoding)”, the number 0x0064732E, which is the two DEC spellings below (00 64 73 2E and 2E 73 64 00) depending on
which end the number is written from; libSoX’s source, which says “DEC uses a slight variation and swaps bytes”, treats
00 64 73 2E as the little-endian one. The sources do not settle the byte order, and
the explorer accepts both.
libSoX’s au.c accepts two more spellings of the magic number that DEC used:
00 64 73 2E (“\0ds.”), a little-endian file like dns., and
2E 73 64 00 (“.sd\0”), the same bytes read the other way, a big-endian file. No
specification describes them; the explorer reads all four magic numbers.
Three more readers disagree about which byte order goes with which spelling. Java’s AuFileReader reads the magic
as a big-endian integer and takes 0x2E736400 (bytes 2E 73 64 00) as a big-endian file and
0x0064732E (bytes 00 64 73 2E) as a little-endian one, as libSoX does. The file(1)
magic database (Magdir/audio) matches lelong 0x0064732E, which is the bytes 2E 73 64 00,
and reads the fields after it as little-endian (“DEC audio data”, MIME type audio/x-dec-basic), as the
FAQ’s “0x0064732E in little-endian encoding” also reads. So bytes 2E 73 64 00 are a big-endian file in
Java and libSoX and a little-endian file in file(1), and no real file written by a DEC system was found to decide.
The explorer follows libSoX and Java.
How readers and writers treat the header
The header leaves some cases open, and tools settle them differently. What each does, from its source or, for Apple’s Core Audio and FFmpeg 8, from probe files made from one 16-bit mono sound of 11,025 frames:
| Case | Explorer | Core Audio (afconvert) | FFmpeg 8 | libsndfile |
|---|---|---|---|---|
au_data_size 0xFFFFFFFF | to the end of the file | whole audio | whole audio | accepted as unknown |
| size larger than the file | what follows, with a problem | what follows | what follows | what follows (“should be” in its log) |
| size smaller than the audio | the size, rest flagged as bytes after the audio | the size | everything to the end | the size |
| size 0, audio follows | the audio, with a problem | empty sound | refuses to open | reads it as a sound of 0 frames |
au_offset below 24 | audio from byte 24, with a problem | accepts | audio from byte 24 | offset used as given |
| size not a whole number of frames | whole frames, the rest flagged | whole frames | everything to the end | whole frames |
dns. (little-endian) | read | cannot open | cannot open | read and written |
| encodings 23 to 26 (G.72x) | decoded | cannot open | decoded (24 as G.722; 23, 25 and 26 as ITU G.726, which differs slightly from Sun’s code) | decoded 23, 25, 26; 24 not |
Other readers: libSoX reads the four magic numbers above, takes the annotation as comments and treats a size of
0xFFFFFFFF as unknown. Java’s AuFileReader reads only .snd, refuses an offset
below 24, a sample rate or channel count of 0 and every encoding but 1 to 7 and 27, and skips the annotation unread.
Python’s sunau (removed in Python 3.13) reads only .snd and encodings 1, 2, 3, 4, 5 and 27,
refuses an offset below 24 or above 100 and 0 channels, and keeps the annotation up to its first zero byte.
Writers: libsndfile and Java write an offset of 24 and a size of 0xFFFFFFFF when the audio is over 2 GiB
(2,147,483,647 bytes); FFmpeg writes 0xFFFFFFFF first and fills in the size when it can seek.
NeXT’s own reader, SNDReadSoundfile in the SoundKit source (filesound.c, fixHeader,
in Apple’s Darwin 0.1 release), is stricter about the audio than any of these. It does not trust the stored size: for an
encoding with a fixed sample width it takes the audio as everything from the data offset to the end of the file, cut to a
whole number of frames. A data offset below 24 becomes 24 and the annotation is treated as empty; otherwise the byte before
the data offset is forced to zero, ending the annotation text. A sample rate from 7,091 to 8,029 Hz is changed to the
hardware CODEC rate, 8012.8210513 Hz. The explorer does not apply these changes: it shows the header as stored and takes
the size from the header, with the problems listed above.
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 |
Source: Oracle Solaris 11.2, au(4) man page (the au_filehdr structure, the 24-byte header, AUDIO_AU_FILE_MAGIC 0x2e736e64, AUDIO_AU_UNKNOWN_SIZE ~0, the optional information field); Sun’s usr/src/head/audio/au.h (illumos copy); NeXT’s soundstruct.h (SNDSoundStruct, the four-byte info minimum, the four hardware rates). The field table, the magic number, the unknown-size value and the rates were compared with these texts by script.