Mortal Kombat X sound format

Codecs, formats, encoding/decoding of game audio, video and music
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Mortal Kombat X sound format

Post by spider91 »

It's something about FMOD, but i can't see any FSB header, only the FEV file. Can someone take a look and manage how to unpack mkx sounds? Not sure, but fsb's seems to be encrypted.

https://mega.co.nz/#!IsRDABjI!135retu2s ... 43NZvTPgZ4

Update. Fsb files are encrypted. The key is 996164B5FC0F402983F61F220BB51DC6 , but steel need unpacker for .xxx files, cause gildor's extractor doesn't work.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Mortal Kombat X sound format

Post by aluigi »

Let's take the SND_MUS_DestroyedCity.xxx example.
Basically there you have "data" (encrypted fsb) from offset 0x4d21 till the end of the file and it looks like one unique file, so in that case you can just dump it with the hex editor.
Same thing for the other file with data from 0x2cf23.

And now the script :)

Code: Select all

get XXX_SIZE asize
    findloc OFFSET binary "\xfe\x56\x2e\x20"
math i = 0
for OFFSET = OFFSET < XXX_SIZE
    goto OFFSET
    get SKIP long

    findloc NEXT_OFF binary "\xfe\x56\x2e\x20" 0 ""
    if NEXT_OFF == ""
        get NEXT_OFF asize
    endif

    xmath SIZE "NEXT_OFF - OFFSET"

    get NAME basename
    string NAME p "%s_%d.fsb" NAME i
    log NAME OFFSET SIZE

    math OFFSET = NEXT_OFF
next i
If you are interested just to the sound and music, this is the easiest way.

*EDIT* script updated
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Mortal Kombat X sound format

Post by spider91 »

Thats not unique fsb file. Lets take a look at SND_MUS_DestroyedCity.xxx. First file offset is 0x00004d21 and size is 0x01302f40. Second file offset is 0x01307c61 and size is 0x001ae3c0. There is TOC with offsets and sizes at the beginning (for first file it starts from 0x00002f50), but i'm not much familiar with unreal packages, so i don't know how to get number of files and universal way to get the start of the TOC.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Mortal Kombat X sound format

Post by spider91 »

Also i have a problem with extracted ima adpcm files. With -A or without it i can't get playable sounds. And not even can decode it to PCM with ffmpeg.

http://puu.sh/heKc4/5020d388e5.png
http://puu.sh/heKdF/1ae81aef6c.png


Here is the first fsb from SND_MUS_DestroyedCity.xxx and files extracted with fsbext using -A option.

https://mega.co.nz/#!ow5xTAgR!_Djys9dut ... qHExCnJsks


Upd.

Voices are in fsb ogg format. Aluigi, we need new version of fsbext with ogg support, please. More and more games starts to use it.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Mortal Kombat X sound format

Post by aluigi »

For the ogg files there are some solutions to explore:

- rebuilding the raw data of the fsb file in a normal ogg file
- playing the raw data with fmod (don't know if it's possible with the extracted data)
- creating a decoder

It's not even necessary to have this embedded in fsbext, anyone can try to make something that works on the data dumped by fsbext.
I was looking for the first solution but it's more difficult then what it seems.
Any idea is welcome.


Regarding the ima adpcm files I have no solution.
They should be multichannel but even with xbadpdec (the Xbox and IMA adpcm are similar) the output file given to Audacity is not ok.


I have updated the script in the previous post to extract all the FSB archives inside the XXX archives.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Mortal Kombat X sound format

Post by spider91 »

Fmod can't play extracted raw data, it can play only fsb files with its API, but don't know how to extract them.

As about decoder i don't know nothing about oggs. For example in wav files you can simply add header and change freq,channels, etc that your fsbext shows. It shows this info for oggs as well, but i dont know how to recreate ogg header.

As about ideas, is it possible to make a kind of fsb splitter? For example fsb contains 200 files inside, so if you recreate 200 fsbs with only one file inside its possible to use method i described here.
happyend
Posts: 157
Joined: Sun Aug 24, 2014 8:54 am

Re: Mortal Kombat X sound format

Post by happyend »

aluigi wrote:Let's take the SND_MUS_DestroyedCity.xxx example.
Basically there you have "data" (encrypted fsb) from offset 0x4d21 till the end of the file and it looks like one unique file, so in that case you can just dump it with the hex editor.
Same thing for the other file with data from 0x2cf23.

And now the script :)

Code: Select all

get XXX_SIZE asize
    findloc OFFSET binary "\xfe\x56\x2e\x20"
math i = 0
for OFFSET = OFFSET < XXX_SIZE
    goto OFFSET
    get SKIP long

    findloc NEXT_OFF binary "\xfe\x56\x2e\x20" 0 ""
    if NEXT_OFF == ""
        get NEXT_OFF asize
    endif

    xmath SIZE "NEXT_OFF - OFFSET"

    get NAME basename
    string NAME p "%s_%d.fsb" NAME i
    log NAME OFFSET SIZE

    math OFFSET = NEXT_OFF
next i
If you are interested just to the sound and music, this is the easiest way.

*EDIT* script updated


hi~~aluigi~Can the script support fev file extract?
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Mortal Kombat X sound format

Post by spider91 »

Its only for fsb files. Btw, why do you need fev files? Normally they are useless.
happyend
Posts: 157
Joined: Sun Aug 24, 2014 8:54 am

Re: Mortal Kombat X sound format

Post by happyend »

FMOD event player support fev file play fsb file
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Mortal Kombat X sound format

Post by spider91 »

You can extract it using ravioli game tools.

Well, it plays files, but can't extract them :|, so we steel need an extractor.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Mortal Kombat X sound format

Post by id-daemon »

It was relatively easy to unpack the sounds with fmod using their provided API. Working on the tool now.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Mortal Kombat X sound format

Post by id-daemon »

Here you go, a universal FSB extractor for any formats. Needs fmodL.dll from the official fmod package. No error handling, no interface, because I'm lazy. Just give it the .fsb name and it will put all the sounds contained in .WAV format into the same folder.

p.s. tool updated. Please also note that you need the latest fmodL.dll, because it will not work with old versions.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Mortal Kombat X sound format

Post by id-daemon »

A little mistake found in wav header (data length calculated twice longer). Updated.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Mortal Kombat X sound format

Post by id-daemon »

ahem, things got complicated now.

It seems there are 2 kinds of FSB banks in MKX:

1 - big files connected to the end of a package (these can be split with luigi's script)
2 - small files INSIDE of a package

If someone want to get files from there, one needs to unpack .xxx package. It will give many "fmodsourcedata" files, half of them encrypted, half not. He must somehow cut the first 32 bytes of them, decrypt the decrypted ones, and after that, extract FSB with my tool, but it somehow works a little wrong with these small files - some of them are a little cut in the end. I don't know how to fix this yet.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Mortal Kombat X sound format

Post by aluigi »

Maybe the size is aligned?
Or there is a wrong usage of the offset and size, maybe the offset is 32 bytes lower than the real one?
Just trying to give you some possible ideas, I have not checked the files.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Mortal Kombat X sound format

Post by id-daemon »

aluigi wrote:Maybe the size is aligned?


No, these 32 bytes are added by the engine. This is just an information for those who want to extract them.
n97t7f7b57f
Posts: 27
Joined: Tue Apr 21, 2015 2:15 pm

Re: Mortal Kombat X sound format

Post by n97t7f7b57f »

aluigi wrote:Let's take the SND_MUS_DestroyedCity.xxx example.
Basically there you have "data" (encrypted fsb) from offset 0x4d21 till the end of the file and it looks like one unique file, so in that case you can just dump it with the hex editor.
Same thing for the other file with data from 0x2cf23.

And now the script :)

Code: Select all

get XXX_SIZE asize
    findloc OFFSET binary "\xfe\x56\x2e\x20"
math i = 0
for OFFSET = OFFSET < XXX_SIZE
    goto OFFSET
    get SKIP long

    findloc NEXT_OFF binary "\xfe\x56\x2e\x20" 0 ""
    if NEXT_OFF == ""
        get NEXT_OFF asize
    endif

    xmath SIZE "NEXT_OFF - OFFSET"

    get NAME basename
    string NAME p "%s_%d.fsb" NAME i
    log NAME OFFSET SIZE

    math OFFSET = NEXT_OFF
next i
If you are interested just to the sound and music, this is the easiest way.

*EDIT* script updated

does quick BMS able to decrypt/encrypt fsb?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Mortal Kombat X sound format

Post by aluigi »

No because the algorithm is specific only for the fsb archive and so not worth to be implemented in quickbms.
fsbext is the only to support this encryption and there is even a command-line option to decrypt the archives without extracting them.
n97t7f7b57f
Posts: 27
Joined: Tue Apr 21, 2015 2:15 pm

Re: Mortal Kombat X sound format

Post by n97t7f7b57f »

happyend wrote:Can the script support fev file extract?

Extraction of fmod files (.fev and .fsb)
from decompresed MKX packages(SND_.XXX)

Put your SND_ files in "input" folder
Run "extract_SND.bat"
In "FMOD" folder you will find decrypted fev's and fsb's