|
|
The `fmt ` (space included) chunk describes the format of how the sample data is stored and how it should be interpreted and decoded.
|
|
|
|
|
|
## Format
|
|
|
|
|
|
Sizes and offsets in bytes.
|
|
|
|
|
|
| Offset | Size | Name | Description |
|
|
|
| ------ | ----:| ---- | ----------- |
|
|
|
| 0x00 | 4 | Chunk ID | "fmt " (0x666D7420) |
|
|
|
| 0x04 | 4 | Data Size | Chunk length. Always at least 16 |
|
|
|
| 0x08 | 2 | Compression Code | [Sample data compression format](#compression-codes) |
|
|
|
| 0x0a | 2 | Channel Count | 1–65,535 |
|
|
|
| 0x0c | 4 | Sample Rate | 1–4,294,967,295 Hz[^1] |
|
|
|
| 0x10 | 4 | Average BPS | 1–4,294,967,295 bytes per second[^2] |
|
|
|
| 0x14 | 2 | Block Alignment | 1–65,535 bytes |
|
|
|
| 0x16 | 2 | Sample Bit Depth | 2–65,535 bits |
|
|
|
| 0x18 | 2 | Extra Format Bytes Length | May be omitted if `0`. Data Size is equal to this value plus 16. |
|
|
|
| 0x1a | n | Extra Format Bytes | Must be absent if Extra Format Bytes Length is 0 or omitted. |
|
|
|
|
|
|
[^1]: Per-channel amount. 48,000 means 48,000 samples *per channel* not samples *total.*
|
|
|
|
|
|
[^2]: How many bytes need to be streamed to a DAC in order to maintain smooth playback.
|
|
|
|
|
|
- Format string: `<4sIHHIIHH`
|
|
|
- Does not read Extra Format Bytes Length since it's not always present. If Data Size > 16, read one additonal `H`.
|
|
|
|
|
|
## Compression Codes
|
|
|
|
|
|
The Compression Code field specifies how the wave sample data is stored. The following codes are known:
|
|
|
|
|
|
| Code | Descripion |
|
|
|
| ----:| ---------- |
|
|
|
| 0 (0x0000) | Unknown |
|
|
|
| 1 (0x0100) | Uncompressed PCM |
|
|
|
| 2 (0x0200) | Microsoft ADPCM |
|
|
|
| 6 (0x0600) | ITU G.711 a-law |
|
|
|
| 7 (0x0700) | ITU G..711 µ-law |
|
|
|
| 17 (0x1100) | IMA ADPCM |
|
|
|
| 20 (0x1600) | ITU G.723 ADPCM |
|
|
|
| 49 (0x3100) | GSM 6.10 |
|
|
|
| 64 (0x4000) | ITU G.721 ADPCM |
|
|
|
| 80 (0x5000) | MPEG |
|
|
|
| 65,656 (0xFFFF) | Experimental |
|
|
|
|
|
|
## Extra Format Bytes
|
|
|
|
|
|
Does not exist for uncompressed files.
|
|
|
If data is compressed, this may contain any additional data needed to correctly decompress the samples. Therefore, the format of this section depends on the compression algorithm in use. |
|
|
\ No newline at end of file |