AIFF Format

From ModdingWiki
Jump to navigation Jump to search
AIFF Format
Format typeSound
HardwarePCM
Number of sounds1
Sampling rateAny
Channel countAny
Bits per sample1 - 32
Compressed?No
Tags?Name
Games

The AIFF Format is a file format for storing digital audio (waveform) data. It supports a variety of bit resolutions, sample rates and channels. The format is a subset of the Interchange File Format (IFF).

Data in the AIFF format is stored in chunks. Each chunk begins with a 4 character chunkId which is often a recognizable ASCII sequence, and is followed by a 32-bit chunk length, and then the payload for that chunk.

General Layout

In general there is no restriction on the order of chunks in an AIFF file

The minimum layout would be


Type Name Description
FOURCC formID FORM.
UINT32BE fileLength Length of the file (less the 8 bytes for the FORM header and length).
FOURCC aiffID AIFF identifies this as an AIFF file.
FOURCC chunkID Type of chunk.
UINT32BE chunkLength Length of the chunk (less the 8 bytes for the chunkID and length).
... etc More chunks until the file is complete.

Common Chunk

The common chunk describes way that the sample data is organised in the AIFF file.

Type Name Description
FOURCC chunkID 'COMM'.
UINT32BE chunkLength Length of the chunk.
UINT16BE numChannels Number of channels.
UINT32BE numSampleFrames Number of samples in the file FOR EACH CHANNEL.
UINT16BE sampleSize Number of bits per sample.
Extended sampleRate Number of samples per second PER CHANNEL. (80-bit IEEE 754 floating point value)

Sound Data Chunk

The data chunk contains the sample data.

PCM data is represented in twos-complement form. i.e 16-bit sample data ranges from -32768 to +32767, the zero-crossing point is at 0.

If the number of bits per channel is not divisible by 8, the sample is left justified within the binary field. i.e. only the most significant bits are used; the unused least significant bits should be zeroed.

If the number of bits per channel is more than 8, the data is stored in a big-endian fashion.

If the number of channels is more than 1, then the channels are interleaved. The first sample is stored for each of the channels, then the second sample for each of the channels etc.

There are some standard channel orders.

stereo: Left, Right

3 channel: Left, Right, Center

4 channel: Left, Center, Right, Surround

Quad: Front Left, Front Right, Rear Left, Rear Right

6 channel: Left Center, Left, Center, Right Center, Right, Surround

Type Name Description
FOURCC chunkID 'SSND'.
UINT32BE chunkLength Length of the chunk.
UINT32BE offset Offset to first sample.
UINT32BE blockSize Size of blocks if the application requires fixed size blocks (0 otherwise).
UINT8[] data Sample data packed as described above.

If the application uses fixed sized blocks, then the size of the blocks is specified by the blockSize field. If the sample data does not start at the beginning of the first block, then an offset values indicates how many bytes into the first block is the first sample. The part of the block prior to the first sample should be zeroed. If the last sample is not at the end of the last block, then the remaining bytes in the last block should be zeroed.

Other Chunks

Other optional chunks may appear in the file.

FourCC Name Description
'MARK' Marker A list of named positions in the file, used as cue points.
'INST' Instrument Data contains information that might be used by a sampler to play the waveform. e.g. information about looping for a sustain effect, or maximum and minimum velocities to support.
'MIDI' MIDI Data A place to store MIDI data, most often SysEx messages.
'AESD' Audio Recording Information pertinent to audio recording devices
'APPL' Application Specific Data specific to the application that created the AIFF file. The chunk contains an application Id, and the payload is application specific.
'COMT' Comments A list of text comments.
'NAME' Name A name for the sample.
'AUTH' Author The author of the sample;
' (c) ' Copyright A copyright message.
' ANNO' Annotation Any annotations.

Credits

This file format was documented by Val Mushinskiy. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)