WAV (File Format)
From Wexos's Wiki
(Redirected from WAV)
WAV is a common file format for storing sound data. The WAV format is extended from RIFF.
File Format
The file byte order is always little endian.
RIFF Header
The file starts with the common RIFF header which has the following structure:
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | File magic. Always RIFF in ASCII. |
0x04 | UInt32 | Size of data after this field. |
0x08 | UInt32 | RIFF type. For WAV files this must be WAVE. |
fmt Block
The fmt block contains general information about the sound. It has the following structure:
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always fmt in ASCII. |
0x04 | UInt32 | Size of data following this structure, which is included in this block. |
0x08 | UInt16 | Audio format Specifies what type of audio the data block stores. |
0x0A | UInt16 | Number of channels. |
0x0C | UInt32 | Sample rate. |
0x10 | UInt32 | Byte rate. |
0x14 | UInt16 | Block align. |
0x16 | UInt16 | Bits per sample. Specifies the size of one channel audio sample in bits. |
data Block
The data block stores all the actual audio data.
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always data in ASCII. |
0x04 | UInt32 | Size of data after this field, which is the size of the audio data (A). |
0x08 | Byte[A] | Audio data. The data stores the samples frame, meaning the sample of channel 1 in the first frame is stored first, then the sample of channel 2 in the first frame, and so on. After that comes the samples for the next frame, and so on. |