BRSTM (File Format)

From Wexos's Wiki
Revision as of 17:20, 1 May 2024 by Wexos (talk | contribs) (Imported from avsys wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The BRSTM (Binary Revolution STreaM) file format is used for storing music streams on Wii.

File Format

Header

The file starts with the following header:

Offset Type Description
0x00 Char[4] File magic. Always RSTM in ASCII.
0x04 UInt16 Byte-order-mark. FE FF for big endian, FF FE for little endian.
0x06 UInt16 Version number of the file format.
0x08 UInt32 File size in bytes.
0x0C UInt16 Header size in bytes.
0x0E UInt16 Number of sections stored in the file.
0x10 UInt32 HEAD offset.
0x14 UInt32 HEAD section size in bytes.
0x18 UInt32 ADPC offset.
0x1C UInt32 ADPC section size in bytes.
0x20 UInt32 DATA offset.
0x24 UInt32 DATA section size in bytes.

Reference

Offset Type Description
0x00 Byte Type ID. Stores the pointer type, 0 means it's an absolute address in memory and 1 means it's an offset relative to a value in the file.
0x01 Byte Data type. A reference can link to different structs depending, this value specifies which one. Up to 4 different structs can be used.
0x02 Byte[2] Padding.
0x04 UInt32 Offset.

HEAD

Offset Type Description
0x00 Char[4] Section magic. Always HEAD in ASCII.
0x04 UInt32 Section size in bytes.
0x08 Reference Data info reference, relative to 0x08 into this structure.
0x08 Reference Track info table reference, relative to 0x08 into this structure.
0x08 Reference Channel info table reference, relative to 0x08 into this structure.

Data Info

Offset Type Description
0x00 Byte Sound encoding.
ID Description
0x00 PCM 8
0x01 PCM 16
0x02 DSP ADPCM
0x01 Byte Loop flag.
0x02 Byte Number of channels.
0x03 Byte Sample rate 24. Contains the upper byte of a 24-bit value.
0x04 UInt16 Sample rate.
0x06 UInt16 Block header start.
0x08 UInt32 Loop start in frames.
0x0C UInt32 Loop end in frames.
0x10 UInt32 DATA offset.
0x14 UInt32 Number of stream blocks.
0x18 UInt32 Stream block size in bytes.
0x1C UInt32 Stream block size in samples.
0x20 UInt32 Last stream block size in bytes.
0x24 UInt32 Last stream block size in samples.
0x28 UInt32 Last stream block size in bytes, including padding.
0x2C UInt32 ADPCM data interval.
0x30 UInt32 ADPCM data size.

Track Info Table

Offset Type Description
0x00 Byte Number of track infos.
0x01 Byte Data type.
0x02 Byte[2] Padding.

After comes an array of references which points to each track info.

Track Info

Data type 0
Offset Type Description
0x00 Byte Number of channels (N).
0x01 Byte[N] Channel index table.
Data type 1
Offset Type Description
0x00 Byte Volume.
0x01 Byte Pan.
0x02 Byte[2] Padding.
0x04 UInt32 Reserved.
0x08 Byte Number of channels (N).
0x09 Byte[N] Channel index table.

Channel Info Table

Offset Type Description
0x00 Byte Number of channel infos.
0x01 Byte[3] Padding.

After comes an array of references which points to each channel info.

Channel Info

A channel info contains data used to decode DSP ADPCM sound data. Each entry has the following structure:

Offset Type Description
0x00 Int16[8][2] Coefficients.
0x20 UInt16 Gain.
0x22 UInt16 Pred scale.
0x24 Int16 Yn 1. History sample 1.
0x26 Int16 Yn 2. History sample 2.
0x28 UInt16 Loop pred scale.
0x2A Int16 Loop yn 1. Loop history sample 1.
0x2C Int16 Loop yn 2. Loop history sample 2.
0x2E Byte[2] Padding.

ADPC

Offset Type Description
0x00 Char[4] Section magic. Always ADPC in ASCII.
0x04 UInt32 Section size in bytes.
0x08 UInt16[][2] Seek history. Contains PCM 16 samples of various parts of the stream.

DATA

Offset Type Description
0x00 Char[4] Section magic. Always DATA in ASCII.
0x04 UInt32 Section size in bytes.
0x08 UInt32 Data offset, relative to this field. Points to the start of the sound data.

Tools

The following tools can handle BRSTM files:

  • BrawlBox, by Kryal & BlackJax