BRS (File Format)

From Luma's Workshop
Revision as of 08:11, 28 December 2024 by AwesomeTMC (talk | contribs) (Add more documentation)
Jump to navigation Jump to search
This page is in progress and may contain incomplete information or editor's notes.

BRS (Binary Remix Sequence) files contain sequence data for the NoteFairy (Rainbow Notes) object. Super Mario Galaxy and Super Mario Galaxy 2 each contain only one BRS file, located in AudioRes/Info/JaiRemixSeq.arc/brs/defaultremixseq.brs.

Header

The BRS format contains no header magic like most files do. Instead, it consists of a Sequence Count and Offsets. The size of the header is 0x4 + (Sequence Count x 0x4):

Offset Type Description
0x00 UInt32 (0x4) Sequence Count

Offsets

Each offset holds the offset of a Sequence relative to the beginning of the file and is formatted like this:

Offset Type Description
0x00 UInt32 (0x4) Offset

Sequence Header

Each sequence's header consists of a Track and Note Count:

Offset Type Description
0x00 UInt32 (0x4) Track Count
0x04 UInt32 (0x4) Note Count

Unused/Unknown Section

The header is followed by a section that doesn't seem to do anything. This section's size is Note Count x 0x4.

Offset Type Description
0x00 UInt32 (0x4) Unused/Unknown

Track

Each Track starts by defining its instrument (0x4), followed by the individual Key-presses for a Note (0x10 each). There is no padding between Tracks.

Only 16 keys can be played at once.

Instrument

Offset Type Description
0x00 UInt16 (0x2) Not used
0x02 UInt8 (0x1) Bank Number
0x03 UInt8 (0x1) Program Number

Key

Duration's intended range is 0-1440 after being scaled. Any value above 1440 is clamped to 1440. However, due to the first 3 bytes being discarded at one point, a scaled duration above 255 can cause unexpected behavior.

For instance, if a scaled duration is 0x1234, it is clamped to 0x05A0 (1440) and the 0x05 is discarded later on, making 0xA0 (160) how long it actually plays for.

The tempo at any given time is calculated using: (player_magnitude * 3600.0) / (note_fairy_path_length / note_count)

The scaled duration is calculated using: (120.0 * duration / tempo)

Offset Type Description
0x00 UInt32 (0x4) Key (0x00 = C-1, 0x60 = C4 (middle C), 0x7F = G9, FFFFFFFF = None)
0x04 UInt32 (0x4) Velocity. Valid range: 0-127.
0x08 UInt32 (0x4) Duration (in ticks?). Scaled to the tempo the song is being played at.

Valid range: 0-255 after being scaled.

0x0C UInt32 (0x4) Delay (in ticks?)

Sequences in SMG & SMG2

A sequence can be defined in Obj_arg4 for the NoteFairy object. Obj_arg4 directly corresponds to the sequence index in defaultremixseq.brs. The following sequences are available in both games:

Obj_arg4 Name Note Count Notes
0 Super Mario Bros. main theme (long) 13 Unused
1 Super Mario Bros. main theme (short) 7 Unused
2 Super Mario Bros. underground theme 43
3 Super Mario Bros. main theme (short) 7 Unused
4 Super Mario Bros. underwater theme 46
5 Super Mario World bonus room theme 64