Bwav
Bwav is an audio stream format used by the aal::atom library. It is primarily a lightweight header followed by audio sample data.
File Structure
Bwav is little-endian. The file alignment is 4 bytes despite the sample data alignment. This page is based on version 1, which is the only currently known version.
- Header
- Channel Info Array
- Channel Sample Data Array
Structures
Header
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | Magic - "BWAV" |
| 0x4 | 0x2 | u16 | Byte Order Mark |
| 0x6 | 0x2 | u16 | Version |
| 0x8 | 0x4 | u32 | Samples Hash - Hash of sample data region? |
| 0xc | 0x2 | u16 | Flags - Bit 0 indicates this is a prefetch bwav |
| 0xe | 0x2 | u16 | Channel Count |
Channel Info
Immediately follows header. One channel info per channel, variable length though almost always 0x4c (with 1 loop point). Channel info is tightly packed one after the other.
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 | u16 | Encoding - 0 = Pcm16, 1 = DspAdpcm, 2 = Opus |
| 0x2 | 0x2 | u16 | Channel Pan - 0 = Left, 1 = Right, 2 = Center, 3 = LFE, 4 = LS, 5 = RS, 6 = Invalid? |
| 0x4 | 0x4 | u32 | Sample Rate |
| 0x8 | 0x4 | u32 | Non-Prefetch Sample Count |
| 0xc | 0x4 | u32 | File Sample Count (identical to previous field when non-prefetch bwav) |
| 0x10 | 0x20 | u16[16] | Dsp-Adpcm Coefficients |
| 0x30 | 0x4 | u32 | Non-Prefetch Sample Data Offset |
| 0x34 | 0x4 | u32 | Sample Data Offset |
| 0x38 | 0x2 | u16 | Loop Point Count - Only observed as 1 despite support for multiple |
| 0x3a | 0x2 | u16 | Base Loop Point - Default loop point |
| 0x3c | 0x4 | u32 | Loop End - base sample of end after final loop point, 0xffff'ffff suggests no loop |
| 0x40 | 0xc * Loop Point Count | Loop Point | Loop Point Array - variable sized array of loop points |
Loop Point
A loop point provides a seek point to a specific sample offset. Often only 1 loop point exists, it's role being the start of a single looping region.
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | Loop Start - base sample of loop point start |
| 0x4 | 0x6 | Adpcm Context | Adpcm Context - Snapshot of dsp-adpcm context at the sample offset of loop start |
| 0xa | 0x2 | Zero-padding |
Adpcm Context
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 | u16 | Predictor Scale |
| 0x2 | 0x4 | s16[2] | History Array |
Sample Data
The start of each channel's sample data is aligned up by 64 bytes in file, despite the 4-byte file alignment, outside the last channel, which is truncated to the last non-zero sample (including zeroed samples in a dsp-adpcm block).
| Format | Type | Description |
|---|---|---|
| Pcm16 | 2 bytes per sample | 16-bit signed PCM sample data. |
| Dsp-Adpcm | 8-byte block array, up to 14 samples per block | 8-bit header for decoding, followed by up to 14 4-bit compressed samples. |
| Opus | Header followed by opus data. |