NAME audiofile - file format for audio data SYNOPSIS #include <multimedia/libaudio.h> DESCRIPTION An audio file is composed of three parts: a 24-byte header, a variable-length annotation block, and a contiguous segment of audio data. Audio header and data fields are stored in network (big-endian) byte order, regardless of the native byte-order of the machine architecture on which an applica- tion may be running. Therefore, multi-byte audio data may require byte reversal in order to operate on it by the arithmetic unit of certain processors. The header is defined by the following structure: typedef unsigned long u_32; /* unsigned 32-bit integer */ typedef struct { u_32 magic; /* magic number */ u_32 hdr_size; /* byte offset to start of audio data */ u_32 data_size; /* data length, in bytes (optional) */ u_32 encoding; /* data encoding enumeration */ u_32 sample_rate; /* samples per second */ u_32 channels; /* number of interleaved channels */ } Audio_filehdr; The magic field always contains the following constant: AUDIO_FILE_MAGIC ( 0x2e736e64 ) /* ".snd" */ The hdr_size field contains the length of the fixed header plus the variable-length annotation field. Consequently, it may be interpreted as an offset from the start of the file to the beginning of the audio data. The data_size field contains the length, in bytes of the audio data segment. If this length is not known when the header is written, it should be set to AUDIO_UNKNOWN_SIZE, defined as follows: AUDIO_UNKNOWN_SIZE ( ~0 ) /* (unsigned) -1 */ When the data_size field contains AUDIO_UNKNOWN_SIZE, the length of the audio data may be determined by subtracting hdr_size from the total length of the file. The encoding field contains one of the following enumerated keys: AUDIO_ENCODING_MULAW_8 (1) /* 8-bit ISDN u-law */ AUDIO_ENCODING_LINEAR_8 (2) /* 8-bit linear PCM */ AUDIO_ENCODING_LINEAR_16 (3) /* 16-bit linear PCM */ AUDIO_ENCODING_LINEAR_32 (5) /* 32-bit linear PCM */ AUDIO_ENCODING_FLOAT (6) /* 32-bit IEEE floating point */ AUDIO_ENCODING_DOUBLE (7) /* 64-bit IEEE floating point */ AUDIO_ENCODING_ADPCM_G721 (23) /* CCITT g.721 4-bit ADPCM */ AUDIO_ENCODING_ADPCM_G723_3 (25) /* CCITT g.723 3-bit ADPCM */ AUDIO_ENCODING_ALAW_8 (27) /* 8-bit ISDN A-law */ All of the linear formats are signed integers, centered at zero. Another common linear format, 8-bit unsigned linear PCM, is not currently supported. The floating-point formats are signed, zero-centered, and normalized to the unit value ( -1.0 <= x <= 1.0 ). The sample_rate field contains the audio sampling rate, in samples per second. Common sample rates include 8000, 11025, 16000, 22050, 32000, 44100, and 48000 samples per second. The channels field contains the number of interleaved data channels. For monaural data, this value is set to one. For stereo data, this value is set to two. More than two data channels may be interleaved, but such formats may not be supported by all audio applications. Following the header structure is a variable-length annota- tion field. The contents of this field are currently unde- fined, except that its length must be a non-zero multiple of eight bytes and it must be terminated with at least one null (zero) byte. The audio data segment begins on an eight-byte boundary immediately following the annotation field. Audio data is encoded in the format identified by the file header. The current implementation supports only a single audio data segment per file. NOTES Applications are encouraged NOT to decode the fields of the audio file header directly. Instead, applications should use the routines described in /usr/demo/SOUND/man/man3/audio_filehdr.3 to read, write, and decode audio file headers. The variable-length annotation field is currently ignored by most audio applications. It is present for interchange compatibility. In the future, applications may use this field to store structured data annotation, such as markers and edit points.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |