BRSTM (File Format)
This article describes the BRSTM format, the music format used by Mario Kart Wii, Super Smash Bros. Brawl, and many others.
The file begins with the header, which is 0x64 bytes. All lengths are written in Hexadecimal.
|0x00||4||File magic. RSTM in ASCII.|
|0x04||2||Byte order mark (BOM): The value is always 0xFEFF. If value 0xFFFE is read, then the false endian is used. MKWii uses nearly always big endian (bytes 0xFE,0xFF).|
|0x06||2||Unknown. Usually 01 00.|
|0x08||4||Length of the file in bytes.|
|0x0c||2||Length of header in bytes (always 00 40).|
|0x0e||2||Unknown. 00 02 in most files.|
|0x10||4||Offset location of the HEAD section (usually 00 00 00 40).|
|0x14||4||Size of HEAD section in bytes.|
|0x18||4||Offset location of ADPC section in bytes.|
|0x1c||4||Size of ADPC section in bytes.|
|0x20||4||Offset location of DATA section in bytes.|
|0x24||4||Size of DATA section in bytes.|
|0x28||18||Unknown. Probably padding.|
|End of header|
The rest of the file is written like an Adaptive differential pulse code modulation (ADPCM) file.
The HEAD section is typically 256 bytes long.
It contains what appears to be a ADPCM Table, followed by a a YN1 & YN2 twice, which may control looping. The byte at 0x23 describes the number of channels.
The rest is unknown.
The ADPC section contains what looks like another table.
|0x00||4||Section magic. ADPC in ASCII.|
|0x04||4||Length of section in bytes (typically 00 00 21 60).|
|0x08||2158||Unknown. Probably padding.|
|End of section|
The DATA section contains the ADPCM data, the sounds the file makes.
|0x00||4||Section magic. DATA in ASCII.|
|0x04||4||Length of section in bytes (L = Section Length).|
|0x08||4||Unknown. Number of sub-sections in the ADPCM data?|
|0x30 + L||0A||Padding.|
|End of section|
|End of file|