Apart from being the chemical symbol for gold, and the abbreviation for Australia, AU is also a digital audio format. Short for audio, it was originally invented by Sun Microsystems and NeXT. AU tends to be associated with Unix-based systems, as opposed to Microsoft or Apple machines (which use wav and aiff respectively.) It is also the default audio format for Java programs and applets.

Compared to the RIFF-based wav and aiff formats, AU is reasonably simple. Whereas with a wav you can insert meta-information, cue marks, loop points, or even bitmaps (essentially, anything you like as long as you flag it correctly) an AU file will contain sound data (either straight PCM or compressed) and not much else. Also, while RIFF-based formats are composed of chunks, some of which may contain different audio data or the same audio data compressed differently, an AU file may only contain one data segment.

Format details

AU files always use big-endian ('network') byte order, regardless of the platform they were created on.

The structure of an AU file is as follows:

Diagram split into two halves to fit on screen...

 ------------------------------------------------------------
| Magic  | Data   | Data   | Encoding | Sample |  Number  |
| number | offset | size   |  format  |  freq. |    of    |  --->
|        |        |        |          |        | channels |
 ------------------------------------------------------------
 <------> <------> <------> <--------> <------> <-------->
  4 bytes 4 bytes  4 bytes   4 bytes   4 bytes    4 bytes  

    --------------------------------- // --------------------
     |   Info      |                                         |
---> |   section   |                  Data                   |
     |             |                                         |
    --------------------------------- // --------------------
     <------------> <---------------- // ------------------->
       variable                    variable

The header data is in the form of five unsigned 32-bit integers:

The first four bytes in the file are made up of the 'magic number' 0x2e736e64. In ASCII, this translates to '.snd', and allows programs and the operating system itself to identify the file type.

The next four bytes tell the program reading the file where the audio data starts, in terms of bytes from the start of the file. If there is no information in the information section, this will have the value 24 (or 0x18) which is the total length of the header in bytes. If information is present, this will be 24 plus the length of the information section.

The data size field contains the length of the audio data, in bytes. Because it's possible to work this out by subtracting the data offset from the total file size, this field is not really necessary and can be set to 0xFFFFFFFF to let the program reading the file know that it should calculate the file size itself.

The encoding format field tells the program how to interpret the data within the file. This field can contain one of nine values (in decimal):
1  - 8-bit ISDN u-law
2  - 8-bit linear PCM
3  - 16-bit linear PCM
4  - 24-bit linear PCM
5  - 32-bit linear PCM
6  - 32-bit IEEE floating point
7  - 64-bit IEEE floating point
23 - 4-bit CCITT g.721 ADPCM
24 - CCITT g.722 ADPCM
25 - 3-bit CCITT g.723 ADPCM
26 - 5-bit CCITT g.723 ADPCM
27 - 8 bit ISDN a-law

All the linear PCM formats use signed integers, centered at zero, and the floating point formats are signed, zero-centered, and normalized to the unit value ( -1.0 <= x <= 1.0 ).

The sample frequency field contains a value for the sample rate of the file, in samples per second (Hertz). This could potentially be any value, but most programs and sound hardware will only support a few sample rates (8000, 11025, 16000, 22050, 32000, 44100, and 48000 Hz are the most common.)

The number of channels field tells the program how many interleaved sound channels to expect in the file. For mono audio, there is only one channel, so every sample belongs to the same channel. For stereo, there are two channels, and the samples are interleaved in such a way that every second sample belongs to the same channel. It is possible to use more than two channels in an AU file, but this isn't supported by many programs.

After the header comes the information section. The contents of this section are not actually defined in the AU standard - the only limitation is that its length must be a multiple of eight bytes, and it must be terminated by at least one null byte (i.e., a byte where each bit is a zero). Programs can use this section to store custom data - a description of the file, or loop points, for instance - but there is no guarantee that other programs will preserve the data after processing the file, let alone be able to interpret it.

Finally, we get to the meat of the file: the audio data itself. The audio data needs to start on an eight byte boundary - there must be some multiple of eight bytes between the start of the file and the start of the audio data. The program reading the file will interpret the data in the format specified in the header.


Sources:
Header file for Audio, .au: http://www.opengroup.org/public/pubs/external/auformat.html - Sun Microsystems, 1992
Sun .au sound file format: http://astronomy.swin.edu.au/~pbourke/dataformats/au/ - Paul Bourke, 2001