Open yungfox opened 2 months ago
SM64 and MK64 bank files are a slightly different format from OoT--they begin with a 16 byte "header" which contains the following data:
In OoT this information is stored elsewhere in the ROM in a table ("Audiobank Index"), but in SM64 / MK64 this information is prepended to the bank files as described above. AudiobankToC currently only supports the OoT format. It should not be hard to modify the script to handle the SM64 / MK64 format too, you'd just have to read those four words and write a new struct containing their values, though I don't know offhand what the name of that "header" data structure is in the decomp. If you make these changes, please submit a PR.
Alright, I managed to extract the drums but the instruments were still running into a different kind of problem. In my case I was just interested in the drum samples, so I just commented out the parsing of the instruments and the drums apparently were extracted successfully. My output C file has some struct declarations with a bunch of metadata like this:
/* 0x30 */
AudioBankSample bubble_sound_Sample =
{
.codec = 0x0,
.medium = 0x0,
.unk_bit26 = 0x0,
.unk_bit25 = 0x0,
.size = 0x0,
.sampleAddr = (u8*)0x1bb870,
.loop = &bubble_sound_Loop,
.book = &bubble_sound_Book,
};
/* 0x50 */
AdpcmBook bubble_sound_Book =
{
.order = 0x2,
.npredictors = 0x2,
.book = {
-0x68, -0x69, -0x66, -0x62, -0x5f, -0x5b, -0x58, -0x55,
0x822, 0x7dc, 0x794, 0x74e, 0x70b, 0x6ca, 0x68b, 0x64f,
-0x5ac, -0x9a6, -0xc66, -0xe41, -0xf77, -0x1036, -0x109f, -0x10ca,
0xd9d, 0x117d, 0x141c, 0x15d2, 0x16df, 0x1773, 0x17af, 0x17ae,
},
};
/* 0xa0 */
AdpcmLoop bubble_sound_Loop =
{
.start = 0x0,
.end = 0x3620,
.count = 0x0,
.origSpls = 0x0,
};
Is there a way for me to access the actual source bytes of each sample? Cause I see a sampleAddr
, but where am I supposed to query it?
(My end goal is to extract the actual wave samples from the ROM if it wasn't clear already :v)
The sample data itself is in Audiotable, not Audiobank. The C file produced by AudiobankToC is a 1-to-1 copy of the Audiobank file, there isn't any data missing from it. Audiotable may be composed of several files like Audiobank and Audioseq; the bank metadata somewhere indicates which file is being referenced. Once you have the correct file, sampleAddr in Audiobank is the start address within that file, and end (in the AdpcmLoop) is the length.
The data itself is ADPCM encoded, you should look at https://github.com/z64tools/z64audio to convert between that and WAV. You'll need all the AdpcmBook information listed above.
If you're just trying to get a copy of the sounds, this process has been done already a long time ago, google "mario kart 64 soundfont".
I ran
audiobanktoc.py
to convert from a.bin
file I extracted using MK64AudioFiles, and I got the following output:The ROM I extracted it from is the US version with SHA
579c48e211ae952530ffc8738709f078d5dd215e
. I ran it with Python 3.12.6 on macOS Sonoma and Python 3.9.8 on Windows 10 and the output is always the same.Any ideas?