Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:14.3 aifcUp:14. Multimedia ServicesNext:14.4.1 AU_read Objects

14.4sunau -- Read and write Sun AU files

Thesunau module provides a convenient interface to the SunAU sound format. Note that this module is interface-compatible withthe modulesaifc andwave.

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

Field Contents 
magic wordThe four bytes ".snd".
header sizeSize of the header, including info, in bytes.
data sizePhysical size of the data, in bytes.
encodingIndicates how the audio samples are encoded.
sample rateThe sampling rate.
# of channelsThe number of channels in the samples.
infoASCII 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 byteorder.

Thesunau module defines the following functions:

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

Amode of'r' returns aAU_readobject, while amode of'w' or'wb' returnsaAU_write object.

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

Thesunau module defines the following exception:

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

Thesunau module defines the following data items:

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

AUDIO_FILE_ENCODING_MULAW_8
AUDIO_FILE_ENCODING_LINEAR_8
AUDIO_FILE_ENCODING_LINEAR_16
AUDIO_FILE_ENCODING_LINEAR_24
AUDIO_FILE_ENCODING_LINEAR_32
AUDIO_FILE_ENCODING_ALAW_8
Values of the encoding field from the AU header which are supported bythis module.

AUDIO_FILE_ENCODING_FLOAT
AUDIO_FILE_ENCODING_DOUBLE
AUDIO_FILE_ENCODING_ADPCM_G721
AUDIO_FILE_ENCODING_ADPCM_G722
AUDIO_FILE_ENCODING_ADPCM_G723_3
AUDIO_FILE_ENCODING_ADPCM_G723_5
Additional known values of the encoding field from the AU header, butwhich are not supported by this module.


Subsections


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:14.3 aifcUp:14. Multimedia ServicesNext:14.4.1 AU_read Objects
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp