14.4 sunau -- Read and write Sun AU files

The sunau module provides a convenient interface to the Sun AU sound format. Note that this module is interface-compatible with the modules aifc and wave.

An audio file consists of a header followed by the data. The fields of the header are:

Field  Contents 
magic word The four bytes ".snd".
header size Size of the header, including info, in bytes.
data size Physical size of the data, in bytes.
encoding Indicates how the audio samples are encoded.
sample rate The sampling rate.
# of channels The number of channels in the samples.
info ASCII string giving a description of the audio file (padded with null bytes).

Apart from the info field, all header fields are 4 bytes in size. They are all 32-bit unsigned integers encoded in big-endian byte order.

The sunau module defines the following functions:

open(file, mode)
If file is a string, open the file by that name, otherwise treat it as a seekable file-like object. mode can be any of
Read only mode.
Write only mode.
Note that it does not allow read/write files.

A mode of 'r' returns a AU_read object, while a mode of 'w' or 'wb' returns a AU_write object.

openfp(file, mode)
A synonym for open, maintained for backwards compatibility.

The sunau module defines the following exception:

exception Error
An error raised when something is impossible because of Sun AU specs or implementation deficiency.

The sunau module defines the following data items:

An integer every valid Sun AU file begins with, stored in big-endian form. This is the string ".snd" interpreted as an integer.

Values of the encoding field from the AU header which are supported by this module.

Additional known values of the encoding field from the AU header, but which are not supported by this module.

See About this document... for information on suggesting changes.