Author Topic: Importing New Music to your Mario Party Custom Maps  (Read 3343 times)

Offline SubDrag

  • Posts: 6
  • *
Importing New Music to your Mario Party Custom Maps
« on: December 29, 2016, 12:33:26 PM »
I support Mario Party 1, 2, and 3 (US NTSC version only) in my midi tools.  So the process would be:
1) Download and use the N64 Soundbank Tool
http://goldeneyevault.com/viewfile.php?id=302

Find the bank/midi you wish to edit the midi for.  They are listed by address.  If someone can give me the names of each song, I can update the .ini file to name the songs to help there.  You can preview the song in the tool itself.

Example, for Mario Party 1, the first midi loaded is at: 0182AEC8 (Using Bank 4B)
Another one is when you first go in, and Toad says "Hey I'm Toad, I'll show you around Mushroom Village" is at: 01747490 (Using Bank 1E)

Export the soundfont to .dls, using the Write DLS Soundfont button.  If needed, convert the soundfont to .sf2, if your midi authoring tool requires it, using a tool such as Awave.

2) Use a midi tool, to create a song using that soundfont.  Make sure you use the exported soundfont as the instruments.  An example of a free tool is Synthfont.

3) Open the N64 Midi Tool.
Load the ROM of your game.

Find the midi you were editing.  Click import midi (loop checkbox, if desired).

Click Write ROM. 

Note that this does not let you import bigger midis (nor does it update the internal game tables, as this tool is generic), they must be smaller in binary form.

4) Optional, export step.  Import new instruments using N64 Sound Tool to the soundbank (note you would have to actually update your original soundfont with them too), click Inject, and Write ROM.  You can update sfx in Mario Party 1, but not 2 and 3 (but you can edit instruments in all 3 games).
http://goldeneyevault.com/viewfile.php?id=212

Here is a tutorial Punk7890 wrote, though it was a bit more generic:
http://goldeneyevault.com/files/tutorials/miditool[punk7890]/n64miditooltutorial.pdf

Perhaps one day Party Planner 64 can incorporate this functionality, as my tools are open source. Here is the technical info on the tables midis are stored, in case that occurs:

This can also be used to change which soundbank, a particular midi will use.

Mario Party

Midi Listing at 015396A0 (4 byte header S2)
Midi Lookup Soundbank # at 0153992C
SS 7FFFFF000007A000029D280002A4C8
SS = Soundbank #

(Note that I believe actually the soundbank association, though in table, may actually be hardcoded)
Midi Listing at 01778BC0 (4 byte header S2)
Midi Lookup Soundbank # at 01778BFC
SS 7FFFFF000007A000029D280002A4C8
SS = Soundbank #

Mario Party 2

01750490 Midi Lookup (ROM)
00SS0000 07000000 OOOOOOOO LLLLLLLL
SS = Soundbank #
OOOOOOOO=Location of Midi (offset from 01750450)
LLLLLLLL=Length of Midi

Mario Party 3

01881C80 Midi Lookup (ROM)
00??SS00 07000000 OOOOOOOO LLLLLLLL
?? = ?
SS = Soundbank #
OOOOOOOO=Location of Midi (offset from 01881C40)
LLLLLLLL=Length of Midi

Offline PartyPlanner64

  • Posts: 48
  • *
  • 00 
Re: Importing New Music to your Mario Party Custom Maps
« Reply #1 on: January 02, 2017, 07:20:14 PM »
Thanks for the info! It does seem like this would work with the editor, given the restriction of keeping the midis/everything smaller than the originals.

Right now the editor can relocate the entire blob of audio at the end of the ROM as needed, but can't do any sort of manipulation of it.

I have some of these offsets and the others that I found that were hardcoded:
https://github.com/PartyPlanner64/PartyPlanner64/blob/master/js/adapter/audio.js

Presumably a good first step would be to at least make the editor better at breaking down and building back something like the sound bank, even if it doesn't change it.

In the MP1/2/3.js files I have some of the song names (or approximations of them). For example:
https://github.com/PartyPlanner64/PartyPlanner64/blob/1e86be9a5ac382e572184a75de324cbefebf1948/js/adapter/MP1.js#L488

They kind of changed things up in the sequels. MP1 has the most hardcoded offsets, while 2 and 3 have a few less. The sequels have certain magics to identify the sections:
  • MBF0: Midi?
  • SBF0: Sound bank?
  • FXD0: SFX?

Offline SubDrag

  • Posts: 6
  • *
Re: Importing New Music to your Mario Party Custom Maps
« Reply #2 on: January 04, 2017, 03:02:45 PM »
Oh wait, you relocate the midis and soundbanks to the end of the ROM?  If so my tools won't work I'm afraid, unless midis are imported first, because right now they just use hardcoded offsets.  Maybe one day this can be fully integrated into PP64 instead, or at least pulled from offsets.  In theory both sound and music editing can be added.  Though I never did SFX importing, since Mario Party 2/3 had a custom format for that (but instruments were same as other games).

Thanks for the midi names, added them, that should help people adding new ones.  There are some missing, maybe you can identify them later.

Offline PartyPlanner64

  • Posts: 48
  • *
  • 00 
Re: Importing New Music to your Mario Party Custom Maps
« Reply #3 on: January 07, 2017, 01:18:21 PM »
PP64 shifts the entire audio section as needed since the rest of the ROM can grow or shrink. (So it shifts everything from 0x15396A0 and beyond for example.) As far as I know everything from the S2 structure onwards is audio.

So if someone used your tools with a stock ROM to replace the audio and were able to get a working ROM afterwards, I'd guess that they could use PP64 as usual afterwards since the offsets and size of everything audio related wouldn't have changed.

I took down some notes on the audio structures one night:
https://github.com/PartyPlanner64/PartyPlanner64/wiki/Audio

The S2 structure seems pretty reasonable to figure out so far, although I don't know what the 00029D28 and 0002A4C8 are pointing too. They are always the same in what I called a S2SoundBankEntry.

The B1 is more confusing to me (0x1539E40). I get that it has an offset table, but the offsets point to kind of random places in the following data and I don't really get much of the structure from there.

The T3 (0x1832AE0) and FXD0 (0x1CECC60) are both pretty much a mystery to me at the moment. Initially the T3 looked like a bunch of RAM addresses but I don't think it actually is. Even the u16 value which is probably a count of something right after "T3" doesn't immediately make sense.

Offline SubDrag

  • Posts: 6
  • *
Re: Importing New Music to your Mario Party Custom Maps
« Reply #4 on: January 09, 2017, 04:46:29 PM »
Do you keep the Midi table at the same location, and just update the offsets? If so, maybe I can make the midi tool read that, as a special Mario Party type, so it can use that instead of hardcoded offsets. But as you mention, as it stands today, the midis must be imported first, and it would work fine. But once you touch it with PP64, it won't be able to be edited as easily any more. I'll look into that.  Was that for all three Mario Party, or just the first one?

Yeah, the midi wrapper is fairly simplistic, that S2 is basically just midi offset and size.  Following it, there is the table I mentioned and you annotated a bit (not sure what the mystery offsets are either, but they all seemed the same, so it doesn't seem important.  Probably could debug it sometime to see where they actually go to).  I'm not sure I consider it part of the S2 bank...maybe...since other games didn't have this as far as I know, but we can consider it for now.

B1 is the bank format that the N64 Sound Tool fully supports both import and export.  It's 100% supported by my tool, so you can check out that source.  The format is also in the N64 SDK manuals.

I haven't really checked out T3 at all, but most games have a kind of SFX microcode format, that would be my guess as to what it is (without poking around).  Don't believe it's RAM addresses.  Doesn't seem to be much in FX.

Mario Party 2 had a special Sound Effects format (Mario Party 1 did not, and everything used B1).  I called it MarioParty2E, for lack of a better term. It was a lot simpler than the B1 Format, I guess that's why they used it (saved space).  It's basically just the sounds, and lacks the instrument wrapper.  I don't have an import for it, though it could be done, just export, but source is in N64 Sound Tool.  In the US version it's at:
0190A104-01923A04
01CBF484-01CC7354

I think Mario Party 3 went back to the B1 format (or I just missed the SFX bank right now).

Offline PartyPlanner64

  • Posts: 48
  • *
  • 00 
Re: Importing New Music to your Mario Party Custom Maps
« Reply #5 on: January 10, 2017, 08:09:44 PM »
Alright, I found your CN64AIFCAudio::ReadAudio and followed it through and updated my notes. So with this, I should be able to completely parse out the S2 and B1 structures, which means I could rebuild them theoretically to be larger or have different contents if I can understand what in the world I'm dealing with here :). But I can at for sure handle them more carefully and calculate their size now.

The mystery offsets in that table are actually both TBL offsets, one relative to the S2 and another to the B1. So that's nice to avoid hard-coding them.

Right now I do move everything, including the midi table(s), because I just treat it as a big blob of known fixed width. I update the game's code to point to the new locations whereever I end up moving it (so maybe a couple dozen LUI and ADDIU values, as indicated in that audio.js I linked).

In the future though, I would treat each of these different things individually like I do the rest of the ROM (so, I'd relocate the S2s / B1s and whatever else independently because I should now be able to calculate the size of each of them).

One thing I possibly could do eventually then is move the S2/B1 to the very end of the ROM. I'm not sure if that would open up any possibilities with your tool for increasing the midi size.

It does seem like you would be able to do the same kind of parsing you do now with only knowledge of the S2 pointer for this game. So, to get the S2 offset originally equal to 0x15396A0, read the upper value at ROM 0x00061746 and the lower value at 0x0006174A for example. Then you would read the TBL from the "extra S2 table" and I guess just assume whatever the 3rd value is in gameconfigsound.ini. Depends whether you want to add the extra code for it I guess.

Offline SubDrag

  • Posts: 6
  • *
Re: Importing New Music to your Mario Party Custom Maps
« Reply #6 on: January 12, 2017, 12:13:50 PM »
I took the simple way right now, and updated the N64 Midi and Soundbank tool, to load the midi S2 locations from:
00061744,00061748
0006174C,00061750

Seemed to work fine, including modified PP64 ROMs, so that should be a good interim solution for people.  It does not rewrite the S2 table, so your midis still need to be smaller (and it ignores the tbl/ctl offsets for now).  But it should allow imported midis even after being modified by PP64, which I think is a good stopgap till a more complete solution.

Offline SubDrag

  • Posts: 6
  • *
Re: Importing New Music to your Mario Party Custom Maps
« Reply #7 on: January 17, 2017, 03:05:12 PM »
Do you also do this shift to end of ROM for Mario Party 2 and 3, or just Mario Party 1?  I only edited MP1.

Offline PartyPlanner64

  • Posts: 48
  • *
  • 00 
Re: Importing New Music to your Mario Party Custom Maps
« Reply #8 on: January 17, 2017, 05:43:08 PM »
Yes, I do the same approach for all three. Here's the upper and lower ROM asm offsets for Mario Party 2 and Mario Party 3 (U) where I read/patch the audio section offsets.

Offline SubDrag

  • Posts: 6
  • *
Re: Importing New Music to your Mario Party Custom Maps
« Reply #9 on: January 28, 2017, 11:37:13 AM »
Added Mario Party 2 and 3 finally in the N64 Midi Tool to pick up the dynamic offsets. 
Note that the Sound and Soundbank tool only do Midi dynamic offsets (not the soundbank ones), so you should just use the midi tool, and the original exported soundfonts from the clean original ROMs to create new midis (and preview in your composer tool).

At the least now midis can imported in all 3 Mario Parties after being processed by Party Planner 64 (still limitation that new midis must be smaller, as the banks are not rewritten).