MTA2 (Container)

From mgsdevwiki
Jump to: navigation, search

MTA2 containers are used to store music and longer sound effects. Samples are encoded with the MTA2 codec. They are exclusive to Metal Gear Solid 4.

Format

  • Endianness: Big Endian
Header
char {4} Magic ("MTA2")
uint32 {4} Unchunked Size
byte {1} Unknown (0x01)
byte {55} Padding
HEAD Section
char {4} Section ID ("HEAD")
uint32 {4} Section Size (0xb0)
byte {4} Padding
uint32 {4} Unknown (0x10)
uint32 {4} Unknown (0x7f)
uint16 {2} Unknown (0x40)
uint16 {2} Channels * Tracks
uint32 {4} Loop Start Frame
uint32 {4} Loop End Frame
uint32 {4} Unknown (0x10)
uint32 {4} Loop Start Offset ÷ 0x10 (unchunked offset)
uint32 {4} Loop End Offset ÷ 0x10 (unchunked offset)
byte {4} Padding
bool32 {4} Loopping Enabled
byte {8} Padding
float32 {4} Sample Rate (defaults to 48kHz)
byte {120} Padding
TRKP Section (x12)
char {4} Section ID ("TRKP")
uint32 {4} Section Size (0x68)
uint32 {4} Unknown (0x20)
byte {2} Unknown (0x7f7f)
byte {1} Unknown (0x40)
byte {1} Channel Mask (0 if track is unused)
byte {2} Padding
bool8 {1} Track In Use
byte {28} Padding
bool8 {1} Looping Enabled
byte {48} Unknown (see TRKP Unknown)
byte {16} Unknown (0xff)
DATA Section
char {4} Section ID ("DATA")
uint32 {4} Unchunked Size
chunk {x} Sample Chunks...
chunk {2} Loop Chunks..

TRKP Unknown

Some example TRKPs...

BGM, 4-channel, loops (in pair)

54 52 4B 50 00 00 00 68 00 00 00 20 7F 7F 40 33
00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
69 00 69 00 69 00 69 00 69 00 69 00 69 00 69 00
69 00 69 00 69 00 69 00 69 00 69 00 69 00 69 00
69 00 69 00 69 00 69 00 69 00 69 00 69 00 69 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

DLBM, 1-channel, no loop (in pair)

54 52 4B 50 00 00 00 68 00 00 00 20 7F 7F 40 04
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

BGM, 4-channel, 3-track, loops

54 52 4B 50 00 00 00 68 00 00 00 20 7F 7F 40 33
00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
5C 05 00 19 00 23 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

Bottom-half may vary by track... some sort of volume modifier, fade control? All 00's seems to be valid as well.

Channel Mask

Bit Mask Channel
0x1 Front Left
0x2 Front Right
0x4 Front Center
0x8 Low Frequency (Subwoofer)
0x10 Back Left
0x20 Back Right

Sample Chunks

Each chunk is in the same format as an MGS4 DAT.
Chunk types for audio end in 0x1.
0x10001 is used for music, 0x20001 is used for longer sound effects (see vox_n.dat).

Each chunk contains a number of MTA2-encoded sample blocks.

Loop Chunks

Chunk type 0xf0 is used for looping metadata.
The size for this chunk is always 0x10, as the metadata is included in the chunk header.
The first chunk uses the last 4 bytes (item count) to define the offset of the loop start offset. This is the unchunked offset ÷ 0x800.

The second chunk used the third 4 bytes to store an unknown value. This value doesn't seem to have any effect on BGM playback.