1au(4)                            File Formats                            au(4)
2
3
4

NAME

6       au - AU audio file format
7

SYNOPSIS

9       #include <audio/au.h>
10
11

DESCRIPTION

13       An  AU  audio  file  is  composed of three parts: a header, an optional
14       description field, and a contiguous segment of audio data.  The  header
15       is  24 bytes, and the description field is at least 4 bytes. Therefore,
16       the offset for most AU files is 28 bytes. However,  some  people  store
17       additional data in the AU header.
18
19
20       The  AU  audio  structure members and audio data are stored big endian.
21       That is, it starts with the most significant byte,  regardless  of  the
22       native  byte  order of the machine architecture on which an application
23       may be running. Therefore,  multi-byte  audio  data  may  require  byte
24       reversal  for proper playback on different processor architectures. See
25       the macro section for properly reading and writing the AU audio  struc‐
26       ture members.
27
28
29       The AU header is defined by the following structure:
30
31         struct au_filehdr {
32            uint32_t au_magic;       /* magic number (.snd) */
33            uint32_t au_offset;      /* byte offset to start of audio data */
34            uint32_t au_data_size;   /* data length in bytes */
35            uint32_t au_encoding;    /* data encoding */
36            uint32_t au_sample_rate; /* samples per second */
37            uint32_t au_channels;    /* number of interleaved channels */
38         };
39         typedef struct au_filehdr au_filehdr_t;
40
41
42
43       The  au_magic  field  always  contains the following constant for an AU
44       audio file:
45
46         AUDIO_AU_FILE_MAGIC   ( 0x2e736e64 ) /* ".snd" */
47
48
49
50       The au_offset field contains the length of the audio file  header  plus
51       the  variable length info field. Consequently, it can be interpreted as
52       the offset from the start of the file to the start of the audio data.
53
54
55       The au_data_size field contains the length, in bytes, of the audio data
56       segment.  If  this  length  is not known when the header is written, it
57       should be set to AUDIO_AU_UNKNOWN_SIZE, defined as follows:
58
59         AUDIO_AU_UNKNOWN_SIZE  ( ~0 )       /* (unsigned) -1 */
60
61
62
63       When the au_data_size field contains AUDIO_AU_UNKNOWN_SIZE, the  length
64       of  the  audio data can be determined by subtracting au_offset from the
65       total length of the file.
66
67
68       The encoding field contains one of the following enumerated keys:
69
70         AUDIO_AU_ENCODING_ULAW         /* 8-bit u-law */
71         AUDIO_AU_ENCODING_LINEAR_8     /* 8-bit linear PCM */
72         AUDIO_AU_ENCODING_LINEAR_16    /* 16-bit linear PCM */
73         AUDIO_AU_ENCODING_LINEAR_24    /* 24-bit linear PCM */
74         AUDIO_AU_ENCODING_LINEAR_32    /* 32-bit linear PCM */
75         AUDIO_AU_ENCODING_FLOAT        /* Floating point */
76         AUDIO_AU_ENCODING_DOUBLE       /* Double precision float */
77         AUDIO_AU_ENCODING_FRAGMENTED   /* Fragmented sample data */
78         AUDIO_AU_ENCODING_DSP          /* DSP program */
79         AUDIO_AU_ENCODING_FIXED_8      /* 8-bit fixed point */
80         AUDIO_AU_ENCODING_FIXED_16     /* 16-bit fixed point */
81         AUDIO_AU_ENCODING_FIXED_24     /* 24-bit fixed point */
82         AUDIO_AU_ENCODING_FIXED_32     /* 32-bit fixed point */
83         AUDIO_AU_ENCODING_EMPHASIS     /* 16-bit linear with emphasis */
84         AUDIO_AU_ENCODING_COMPRESSED   /* 16-bit linear compressed */
85         AUDIO_AU_ENCODING_EMP_COMP     /* 16-bit linear with emphasis
86                                                       and compression */
87         AUDIO_AU_ENCODING_MUSIC_KIT    /* Music kit DSP commands */
88         AUDIO_AU_ENCODING_ADPCM_G721   /* CCITT G.721 ADPCM */
89         AUDIO_AU_ENCODING_ADPCM_G722   /* CCITT G.722 ADPCM */
90         AUDIO_AU_ENCODING_ADPCM_G723_3 /* CCITT G.723.3 ADPCM */
91         AUDIO_AU_ENCODING_ADPCM_G723_5 /* CCITT G.723.5 ADPCM */
92         AUDIO_AU_ENCODING_ALAW         /* 8-bit A-law G.711 */
93
94
95
96       All of the linear encoding formats  are  signed  integers  centered  at
97       zero.
98
99
100       The  au_sample_rate  field  contains  the audio file's sampling rate in
101       samples per second. Some  common  sample  rates  include  8000,  11025,
102       22050, 44100, and 48000 samples per second.
103
104
105       The au_channels field contains the number of interleaved data channels.
106       For monaural data, this value is set to  one.  For  stereo  data,  this
107       value  is  set  to two. More than two data channels can be interleaved,
108       but such formats are currently unsupported by the Solaris audio  driver
109       architecture.  For  a  stereo  sound file, the first sample is the left
110       track and the second sample is the right track.
111
112
113       The optional info field is a variable length annotation field that  can
114       be  either text or data. If it is a text description of the sound, then
115       it should be NULL terminated. However, some older files  might  not  be
116       terminated  properly. The size of the info field is set when the struc‐
117       ture is created and cannot be enlarged later.
118
119   Macros
120       Accessing all of the AU audio structure members should be done  through
121       the  supplied  AUDIO_AU_FILE2HOST  and  AUDIO_AU_HOST2FILE  macros.  By
122       always using these macros, code will be byte-order independent. See the
123       example below.
124

EXAMPLES

126       Example 1 Displaying Header Information for a Sound File
127
128
129       The  following program reads and displays the header information for an
130       AU sound file. The AUDIO_AU_FILE2HOST macro ensures that this  informa‐
131       tion will always be in the proper byte order.
132
133
134         void main(void)
135         {
136              au_filehdr_t    hdr;
137              au_filehdr_t    local;
138              int             fd;
139              char            *name = "bark.au";
140
141              if ((fd = open(name, O_RDONLY)) < 0) {
142                   printf("can't open file %s\n", name);
143              exit(1);
144              }
145
146              (void) read(fd, &hdr, sizeof (hdr));
147
148              AUDIO_AU_FILE2HOST(&hdr.au_magic, &local.au_magic);
149              AUDIO_AU_FILE2HOST(&hdr.au_offset, &local.au_offset);
150              AUDIO_AU_FILE2HOST(&hdr.au_data_size, &local.au_data_size);
151              AUDIO_AU_FILE2HOST(&hdr.au_encoding, &local.au_encoding);
152              AUDIO_AU_FILE2HOST(&hdr.au_sample_rate, &local.au_sample_rate);
153              AUDIO_AU_FILE2HOST(&hdr.au_channels, &local.au_channels);
154
155              printf("Magic = %x\n", local.au_magic);
156              printf("Offset = %d\n", local.au_offset);
157              printf("Number of data bytes = %d\n", local.au_data_size);
158              printf("Sound format = %d\n", local.au_encoding);
159              printf("Sample rate = %d\n", local.au_sample_rate);
160              printf("Number of channels = %d\n", local.au_channels);
161
162              (void) close(fd);
163         }
164
165

ATTRIBUTES

167       See attributes(5) for descriptions of the following attributes:
168
169
170
171
172       ┌─────────────────────────────┬─────────────────────────────┐
173       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
174       ├─────────────────────────────┼─────────────────────────────┤
175       │Availability                 │SUNWaudh                     │
176       ├─────────────────────────────┼─────────────────────────────┤
177       │Stability Level              │Evolving                     │
178       └─────────────────────────────┴─────────────────────────────┘
179

SEE ALSO

181       attributes(5)
182

NOTES

184       Some  older AU audio files are incorrectly coded with info strings that
185       are not properly NULL-terminated. Thus, applications should always  use
186       the  au_offset value to find the end of the info data and the beginning
187       of the audio data.
188
189
190
191SunOS 5.11                        15 Jan 2001                            au(4)
Impressum