Overview
A BRSTM (Binary Revolution STreaM) is the music format used by Mario Kart Wii and other games such as Super Smash Bros. Brawl.
Offset |
Type |
Description
|
0x00 |
String |
File magic. RSTM in ASCII.
|
0x04 |
UInt16 |
Byte order mark (BOM): The value is always 0xFEFF. If value 0xFFFE is read, then the false endian is used. Mario Kart Wii uses nearly always big endian (bytes 0xFE,0xFF).
|
0x06 |
UInt16 |
Version. Always 0x0100.
|
0x08 |
UInt32 |
File size.
|
0x0c |
UInt16 |
Header size. Always 0x40.
|
0x0e |
UInt16 |
Section count. (Excluding HEAD).
|
0x10 |
UInt32 |
Offset to HEAD section.
|
0x14 |
UInt32 |
Size of HEAD section.
|
0x18 |
UInt32 |
Offset to ADPC section.
|
0x1c |
UInt32 |
Size of ADPC section.
|
0x20 |
UInt32 |
Offset to DATA section.
|
0x24 |
UInt32 |
Size of DATA section.
|
HEAD
Offsets are relative to 0x08 of this header.
Stream Data Info
Offset |
Type |
Description
|
0x00 |
Byte |
Format.
Enum |
Description
|
0x0 |
PCM8
|
0x1 |
PCM16
|
0x2 |
ADPCM
|
|
0x01 |
Byte |
Loop Flag
|
0x02 |
Byte |
Number of channels
|
0x03 |
UInt24 |
Sample rate.
|
0x06 |
UInt16 |
Offset to block header? Always 0.
|
0x08 |
UInt32 |
Loop start sample.
|
0x0C |
UInt32 |
Loop end sample.
|
0x10 |
UInt32 |
Actual data offset.
|
0x14 |
UInt32 |
Block count.
|
0x18 |
UInt32 |
Block size.
|
0x1C |
UInt32 |
Block samples.
|
0x20 |
UInt32 |
Final block size.
|
0x24 |
UInt32 |
Final block samples.
|
0x28 |
UInt32 |
Final block size with padding.
|
0x2C |
UInt32 |
The interval (sample count) for writing data to the ADPC block.
|
0x30 |
UInt32 |
Size per channel for each interval where data is written to the ADPC.
|
Track Table
Offset |
Type |
Description
|
0x00 |
Byte |
N = Track count.
|
0x01 |
Byte |
Track Info type. (0 = Simple, 1 = Extended).
|
0x02 |
Byte[2] |
Padding.
|
0x04 |
DataRef[N] |
Reference to Track Info. Data type needs to match Track Info type.
|
Track Info (Simple)
With "simple" track info Track Volume is set to 127.
Offset |
Type |
Description
|
0x00 |
Byte |
N = Channel count.
|
0x01 |
Byte[N] |
Channel index info.
|
Track Info (Extended)
Offset |
Type |
Description
|
0x00 |
Byte |
Track volume (0-127).
|
0x01 |
Byte |
Pan (0-127).
|
0x02 |
Byte[2] |
Padding.
|
0x04 |
UInt32 |
Reserved.
|
0x08 |
Byte |
N = Channel count.
|
0x09 |
Byte[N] |
Channel index info.
|
Channel Table
Offset |
Type |
Description
|
0x00 |
Byte |
N = Channel count.
|
0x01 |
Byte[3] |
Padding.
|
0x04 |
DataRef[N] |
References to another DataRef referencing ADPCM Parameters Set. Value of 0 is second DataRef means no data.
|
ADPCM Parameters Set
This data is only available if ADPCM encoding is used.
Offset |
Type |
Description
|
0x00 |
UInt16[16] |
Coefficients.
|
0x2C |
UInt16 |
Gain.
|
0x2E |
UInt16 |
Predictor + Scale.
|
0x30 |
UInt16 |
YN1. (Sample - 1).
|
0x32 |
UInt16 |
YN2. (Sample - 2).
|
0x34 |
UInt16 |
Loop Predictor + Scale.
|
0x36 |
UInt16 |
Loop YN1. (Sample - 1).
|
0x38 |
UInt16 |
Loop YN2. (Sample - 2).
|
ADPC
This section is only available if ADPCM encoding is used.
The ADPC chunk contains 2 PCM history samples per channel for every entry in the table. (UInt16)
The number of samples per entry is specified in the HEAD section.
Each entry in the table contains the final two samples from the preceding block.
Offset |
Type |
Description
|
0x00 |
String |
Section magic. ADPC in ASCII.
|
0x04 |
UInt32 |
Size of the section.
|
DATA
The DATA section contains the ADPCM data, the sounds the file makes.
Offset |
Type |
Description
|
0x00 |
String |
Section magic. DATA in ASCII.
|
0x04 |
UInt16 |
Size of the section.
|
0x08 |
UInt32 |
Offset to actual data.
|
Data needs to be 0x20 aligned and it's splitted in blocks.
Data stored with channel alternating every block unlike WAV format, where channels alternate every sample.
(Channel 0 Block 0 -> Channel 1 Block 0 -> Channel 0 Block 1 -> ...)
Data Reference
The Data Reference structure is used to point to other data types.
Offset |
Type |
Description
|
0x00 |
Byte |
Reference type. (0 = Address, 1 = Offset).
|
0x01 |
Byte |
Data type.
|
0x02 |
UInt16 |
Reserved.
|
0x04 |
UInt32 |
Value.
|