Changes

Jump to navigation Jump to search
6,373 bytes added ,  22:57, 29 April 2017
m
→‎HEAD chunk part 1: Fix variable name
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 an a header, followed by a HEAD chunk, a an ADPC chunk and a DATA chunk.<br/>
All the data in those files are big-endian, except where mentioned.<br/>
All the offsets are absolute (from begining beginning of file), except where mentioned.<br/>
All the sizes are in bytes, except where mentioned.<br/>
Each chunk is padded to a multiple of 0x20.<br/>
=== BRSTM header ===
|-
| 0x0004
| 42| Magic Byte Order Mark (0xFEFF0100BOM), usually 0xFE 0xFF for big endian.|-| 0x0006| 1| Major version|-| 0x0007| 1| Minor version
|-
| 0x0008
|-
| 0x000C
| 42| UnknownHeader size|-| 0x000E| 2| Number of chunks
|-
| 0x0010
=== HEAD chunk ===
The head HEAD chunk is typically 256 bytes longcontains 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.<br/>It Part 1 contains what looks like general information about the ADPCM table file such as loop information, sample rate, and YN1data needed to deinterleave the audio stream.<br/YN2>Part 2 defines the tracks in the file, twiceand contains volume and panning information for each of them.<br/>Part 3 contains the information needed to decode the ADPCM audio, probably once for including the first part ADPCM coefficients, and once for history samples. Any offsets in the HEAD chunk are relative to offset 0x08 in the last HEAD chunk unless otherwise noted. ==== Header ===={| class="wikitable"|-! 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? (looping0x01000000) |-| 0x001C| 4| Offset to HEAD chunk part.3|} ==== HEAD chunk part 1 ====This part is 0x34 bytes long{| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 1| Codec:0 - 8-bit PCM<br/>1 - 16-bit PCM<br/>2 - 4-bit ADPCM<br/>It also |-| 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| Bytes per entry in the ADPC table|} ==== HEAD chunk part 2 ==== ===== Header ====={| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 1| Number of tracks|-| 0x0001| 1| Track Description Type|-| 0x0002| 2| Padding? (0x00)|} ===== Offset table =====The header contains some one of this structure for each track{| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 1| 0x01|-| 0x0001| 1| Track description type|-| 0x0002| 2| Padding? (0x00)|-| 0x0004| 4| Offset to track description|} ===== Track Descriptions =====There are at least 2 known types of track descriptions: {| class="wikitable"|-! Type! Description|-| 0 | Used in Super Smash Bros. Brawl|-| 1| Used in other unknown stuffgames.|} The header contains one track description for each track ====== Track Description Type 0 ======{| class="wikitable"|-! 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 1 ======{| class="wikitable"|-! 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 ====={| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 1| Number of channels|-| 0x0001| 3| Padding? (0x00)|} ===== Offset table =====The header contains one of this structure for each channel{| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 4| Marker (0x01000000)|-| 0x0004| 4| Offset to channel information|} ===== ADPCM Channel Information =====The header contains one of this structure for each channel.{| class="wikitable"|-! 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 (Sample - 1)|-| 0x002E| 2| History sample 2 (Sample - 2)|-| 0x0030| 2| Loop predictor/scale<br/>If BRSTM doesn't loop, these will be the same as the initial predictor/scale and history.|-| 0x0032| 2| Loop History sample 1 (Sample - 1)|-| 0x0034| 2| Loop History sample 2 (Sample - 2)|-| 0x0036| 2| Padding (0x00)|}
=== ADPC chunk ===
The ADPC chunk contains 2 PCM history samples per channel for every entry in the table.<br/>The number of samples per entry is typically 1216 bytes longspecified in the HEAD chunk.<br/>It seems to contain some other ADPCM Each entry in the tablecontains the final two samples from the preceding block.<br/>The first entry in the table contains the history samples contained in part 3 of the HEAD chunk. ==== Header ==== {| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 4| "ADPC" (0x41445043)|-| 0x0004| 4| Length of entire ADPC section.|} ==== ADPC table entry====The size of each entry is the channel count * 4{| class="wikitable"|-! Offset! Size! Description|-| 0x0000| 2| Channel 0 History sample 1|-| 0x0002| 2| Channel 0 History sample 2|-| 0x0004| 2| Channel 1 History sample 1|-| 0x0006| 2| Channel 1 History sample 2|-| ...| 2| Channel N History sample 1|-| ...| 2| Channel N History sample 2|}
=== DATA chunk ===
The DATA chunk contains ADPCM sound data.
 
==== Header ====
{| class="wikitable"
|-
! Offset
! Size
! Description
|-
| 0x0000
| 4
| "DATA" (0x44415441)
|-
| 0x0004
| 4
| Length of entire DATA section.
|-
| 0x0008
| 4
| Number of padding samples between header and ADPCM data? Always 0x18
|-
| 0x000C
| 0x14
| Padding (0x00)
|}
 
==== ADPCM Data ====
The ADPCM audio data is interlaced per channel according to the block sizes specified in the header.
 
{| class="wikitable"
|-
! Description
! Size
|-
| Channel 0 block 0
| Block size
|-
| Channel 1 block 0
| Block size
|-
| Channel 0 block 1
| Block size
|-
| Channel 1 block 1
| Block size
|-
| ...
|
|-
| Channel 0 final block
| Final block size
|-
| Channel 1 final block
| Final block size
|}
 
[[Category:File formats]]

Navigation menu