Difference between revisions of "BRSTM file"

From WiiBrew
Jump to navigation Jump to search
(→‎HEAD chunk: Add structure for HEAD chunk)
Line 85: Line 85:
  
  
HEAD chunk header
+
====Header====
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 229: Line 229:
 
|}
 
|}
  
HEAD chunk part 2 header
+
=====Header=====
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 241: Line 241:
 
|}
 
|}
  
 
+
=====Offset table=====
HEAD chunk part 2 offset table<br/>
 
 
The file contains one of this structure for each track
 
The file contains one of this structure for each track
 
{| class="wikitable"
 
{| class="wikitable"
Line 259: Line 258:
 
|}
 
|}
  
HEAD chunk part 2 track table type 1<br/>
+
=====Track Description Type 1=====
 
The file contains one of this structure for each track
 
The file contains one of this structure for each track
 
{| class="wikitable"
 
{| class="wikitable"
Line 284: Line 283:
 
|}
 
|}
  
HEAD chunk part 2 track table type 2<br/>
+
=====Track Description Type 2=====
 
The file contains one of this structure for each track
 
The file contains one of this structure for each track
 
{| class="wikitable"
 
{| class="wikitable"
Line 328: Line 327:
 
====HEAD chunk part 3====
 
====HEAD chunk part 3====
  
HEAD chunk part 3 header
+
=====Header=====
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 344: Line 343:
 
|}
 
|}
  
 
+
=====Offset table=====
HEAD chunk part 3 offset table<br/>
 
 
The file contains one of this structure for each channel
 
The file contains one of this structure for each channel
 
{| class="wikitable"
 
{| class="wikitable"
Line 362: Line 360:
 
|}
 
|}
  
HEAD chunk part 3 channel information table<br/>
+
=====ADPCM Channel Information=====
 
The file contains one of this structure for each channel.
 
The file contains one of this structure for each channel.
 
{| class="wikitable"
 
{| class="wikitable"

Revision as of 06:16, 30 July 2016

BRSTM files contain ADPCM sound data. They are used for music in some games, such as Super Smash Bros. Brawl and Mario Kart Wii.

They contain a header, followed by a HEAD chunk, an ADPC chunk and a DATA chunk.
All the data in those files are big-endian, except where mentioned.
All the offsets are absolute (from begining of file), except where mentioned.
All the sizes are in bytes, except where mentioned.

BRSTM header

The header is 64 bytes long.

Offset Size Description
0x0000 4 "RSTM" (0x5253544D)
0x0004 2 Byte Order Mark (BOM), usually 0xFE 0xFF for big endian.
0x0006 1 Major version
0x0007 1 Minor version
0x0008 4 Size of the whole file
0x000C 2 Header size
0x000E 2 Number of chunks
0x0010 4 Offset to HEAD chunk
0x0014 4 Size of HEAD chunk
0x0018 4 Offset to ADPC chunk
0x001C 4 Size of ADPC chunk
0x0020 4 Offset to DATA chunk
0x0024 4 Size of DATA chunk
0x0028 24 Unknown/Padding (zero)

HEAD chunk

The HEAD chunk contains information about the brstm file, including sample rate, loop information, volume, panning, and information on each of the ADPCM streams.

This chunk contains 3 internal parts.
Part 1 contains general information about the file such as loop information, sample rate, and data needed to deinterleave the audio stream.
Part 2 defines the tracks in the file, and contains volume and panning information for each of them.
Part 3 contains the information needed to decode the ADPCM audio, including the ADPCM coefficients, and history samples.

Any offsets in the HEAD chunk are relative to offset 0x08 in the HEAD chunk unless otherwise noted.


Header

Offset Size Description
0x0000 4 "HEAD" (0x48454144)
0x0004 4 Length of entire HEAD section.
0x0008 4 Marker? (0x01000000)
0x000C 4 Offset to HEAD chunk part 1
0x0010 4 Marker? (0x01000000)
0x0014 4 Offset to HEAD chunk part 2
0x0018 4 Marker? (0x01000000)
0x001C 4 Offset to HEAD chunk part 3


HEAD chunk part 1

This part is 0x34 bytes long

Offset Size Description
0x0000 1 Codec:

0 - 8-bit PCM
1 - 16-bit PCM
2 - 4-bit ADPCM

0x0001 1 Loop flag
0x0002 1 Number of channels
0x0003 0 Padding? (0x00)
0x0004 2 Sample rate
0x0006 2 Padding? (0x00)
0x0008 4 Loop start in samples
0x000C 4 Total sample count
0x0010 4 Absolute offset to the beginning of the ADPCM data.

Note that this is not the beginning of the DATA chunk.

0x0014 4 Total block count.

The total number of interlaced blocks in the ADPCM data. This count includes the final block.

0x0018 4 Block Size in bytes.
0x001C 4 Samples per block.
0x0020 4 Size of the final block without padding in bytes
0x0024 4 Samples in the final block.
0x0028 4 Size of the final block with padding in bytes
0x002C 4 Samples per entry in the ADPC table
0x0030 4 Bits per sample? (0x04 for 4-bit ADPCM)


HEAD chunk part 2

There are at least 2 known types of this part:

Type Marker Description
1 0x01000000 Used in Super Smash Bros. Brawl
2 0x01010000 Used in other games.
Header
Offset Size Description
0x0000 4 Marker
Offset table

The file contains one of this structure for each track

Offset Size Description
0x0000 4 Marker
0x0004 4 Offset to track description
Track Description Type 1

The file contains one of this structure for each track

Offset Size Description
0x0000 1 Number of channels in track
0x0001 1 Left channel ID if stereo track. Only channel if mono.
0x0002 1 Right channel ID if stereo track. 0x00 if mono.
0x0003 1 Padding? (0x00)
Track Description Type 2

The file contains one of this structure for each track

Offset Size Description
0x0000 1 Track volume (0x00 to 0x7F)
0x0001 1 Track panning (0x00 to 0x7F, Left to right)
0x0002 2 Padding? (0x00)
0x0004 4 Padding? (0x00)
0x0008 1 Number of channels in track
0x0009 1 Left channel ID if stereo track. Only channel if mono.
0x000A 1 Right channel ID if stereo track. 0x00 if mono.
0x000B 1 Padding? (0x00)


HEAD chunk part 3

Header
Offset Size Description
0x0000 1 Number of channels
0x0001 3 Padding? (0x00)
Offset table

The file contains one of this structure for each channel

Offset Size Description
0x0000 4 Marker (0x01000000)
0x0004 4 Offset to channel information
ADPCM Channel Information

The file contains one of this structure for each channel.

Offset Size Description
0x0000 4 Marker (0x01000000)
0x0004 4 Offset to channel ADPCM coefficients
0x0008 0x20 16 Int16 ADPCM coefficients
0x0028 2 Gain
0x002A 2 Initial predictor/scale
0x002C 2 History sample 1
0x002E 2 History sample 2
0x0030 2 Loop predictor/scale
0x0032 2 Loop History sample 1
0x0034 2 Loop History sample 2
0x0036 2 Padding (0x00)

ADPC chunk

The ADPC chunk is typically 1216 bytes long. It seems to contain some other ADPCM table.

DATA chunk

The DATA chunk contains ADPCM sound data.