Join also our Discord channel! Click here.

Metal Gear Solid - MTA2 audio format

Get help on any and all audio formats, or chip in and help others!
daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Metal Gear Solid - MTA2 audio format

Post by daemon1 » Wed Apr 22, 2015 12:44 pm

One user asked me if I can look at the sounds from Metal Gear Solid 4. So I checked bgm_mgo_title01.bgm and it looks like 4-channel audio encoded as ADPCM of some kind. 64-sample blocks. If we take first (uncompressed) samples from each block, this is the picture:

Image

and it sounds like some music (probably looped at the end). Let's try some research on this.
Last edited by daemon1 on Sun Apr 26, 2015 7:42 am, edited 1 time in total.

OrangeC
double-veteran
double-veteran
Posts: 860
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 34 times

Re: MTA2

Post by OrangeC » Wed Apr 22, 2015 12:50 pm

Here is an EBOOT.BIN file from the PS3 Demo version incase you need it assuming you are good at looking into game exe's for decoding algorithims.

I will find a MTAF sample file as soon as i find a working MGS 2 or 3 link.

Link Removed
EDIT: Also NOTE that the decoding algorithm for MTAF is inside the vgmstream.dll but I cannot find source code or a decompiled version of it from hcs.
Last edited by OrangeC on Wed Apr 22, 2015 1:25 pm, edited 1 time in total.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Wed Apr 22, 2015 1:01 pm

OrangeC wrote:EDIT: Also NOTE that the decoding algorithm for MTAF is inside the vgmstream.dll but I cannot find source code or a decompiled version of it from hcs.
Yes I found his source, but now we need to know how different is MTA2 from MTAF. It may be very different.

OrangeC
double-veteran
double-veteran
Posts: 860
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 34 times

Re: MTA2

Post by OrangeC » Wed Apr 22, 2015 1:08 pm

Link Removed.

Here is an MTAF file.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Wed Apr 22, 2015 1:54 pm

OrangeC wrote:Here is an MTAF file.
ok, it is really different. 128 samples instead of 64 in MTA2, and probably another algorithm. I will keep you informed. bgm_mgo_lobby01.bgm has 12-channel streams. Weird. Maybe that are 3 parts of one 4-channel music track.

OrangeC
double-veteran
double-veteran
Posts: 860
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 34 times

Re: MTA2

Post by OrangeC » Wed Apr 22, 2015 2:05 pm

Okay thank you. I knew the format was somehow different.

GHzGangster
n00b
Posts: 18
Joined: Fri Aug 15, 2014 6:00 am
Has thanked: 3 times
Been thanked: 1 time

Re: MTA2

Post by GHzGangster » Wed Apr 22, 2015 6:35 pm

Love you guys. :]

bgm_title_mgo has 3 phases/version for sure, each is usually more/less dramatic.

It seems like each phase is denoted by the first byte of each block, then the next 3 bytes are the frame number.
00 00 00 01 ... 0x12c more bytes...
01 00 00 01 ... 0x12c more bytes...
02 00 00 01 ... 0x12c more bytes...
It's like this. For each frame, each version of that frame comes right after.

That EBOOT.BIN is probably useless though. I haven't looked at it, but I'm fairly certain you uploaded the "bootloader". The file you're looking for is MGS4.SELF. I did some debugging, but it seems the sound decoding is done on one of the SPUs (faster than the regular CPU), and it isn't as easy to debug there. Therefore, it's probably some SPU code inside of the ELF, but I really have no experience with SPU stuff right now.

And about the OP, you mentioned taking the first "uncompressed" sample from each block. Did you just take some normal ADPCM algorithm and decode the first sample with that?

Also, just something to note... I was able to take the sample data from one MTA2 and swap it in with another MTA2, and the sound seemed to be playing just fine, other than the loop obviously not working. I don't think there is a lot in the MTA2 that really determines how the actual sample decoding itself is done.

And if you're interested, me and tbg have a Skype chat going on. PM me if you feel like talking about anything. We also emailed the owner of multimedia.cx, he said he would take a look at it, a while ago.

OrangeC
double-veteran
double-veteran
Posts: 860
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 34 times

Re: MTA2

Post by OrangeC » Wed Apr 22, 2015 7:13 pm

Interesting stuff. So how did you manage to get the MTA2 samples playing when you did the swap thing?

tbg
n00b
Posts: 12
Joined: Tue Apr 10, 2012 6:48 pm
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: MTA2

Post by tbg » Wed Apr 22, 2015 7:26 pm

I have some info about this files, but i don't know how to do a conversor, if you want i can share to you.
daemon1, you have a PM.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Wed Apr 22, 2015 7:29 pm

GHzGangster wrote:I did some debugging...
We actually don't need debugging. We just need ADPCM tables for this codec.

I didn't decode the first sample. It is saved in the ADPCM block unchanged. This is what I wanted to check and it was successful.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Wed Apr 22, 2015 7:34 pm

OrangeC wrote:Interesting stuff. So how did you manage to get the MTA2 samples playing when you did the swap thing?
Easily. They are all just a stream of 64 sample-blocks. You can replace them all you want.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Wed Apr 22, 2015 9:04 pm

This is a comparison between the decoded first samples of each frame and same sound recorded from youtube. We can now try and guess where the sample shifts go to decode the whole frames.

Image

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Thu Apr 23, 2015 4:55 pm

Each adpcm block has some 5-bit value. We are trying to find out what can it be. An index for some table, or just a scale?

Image

It seem to correspond the original waveform posted on the top

Image

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Sat Apr 25, 2015 11:32 am

We've calculated an approximate values in the table. Here's the first output. The red points are where the wave gets wrong, because the values are not accurate.

Image

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1945
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 51 times
Been thanked: 1506 times

Re: MTA2

Post by daemon1 » Tue Apr 28, 2015 9:44 pm

Today is a good day for MGS fans. MTA2 codec algorithm was finally figured out with all tables and values. We can now decode any audio from the game.

Post Reply