BMS file

From Pikmin Technical Knowledge Base
Revision as of 03:36, 13 August 2019 by PikHacker (talk | contribs) (started a page on how to make interactive music.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A .bms file holds data for sequenced music in pikmin 1 and 2. Bms files are sort of like midis, but with more advanced features. A custom bms file can be made with Flaaffy by Arookas, which can be found here: https://github.com/arookas/flaaffy/releases.


Documentation:

To do: Actually document every byte of a bms header and music data and what it all means.


Custom Interactive Music:

So you want your pikmin 2 music to have the interactivity of normal pikmin 2 songs? Well, I can tell you how to do that. While Flaaffy made bms files dont have interactivity, enough hex editing can fix that. Note that this all only applies to the four overworld themes. Caves use a completely different system for interactive music that isn't yet understood. Also note that music made this way wont have the Louie swing variant, just the interactive event tracks(working, treasure, enemy near, combat, spiderwort) and the sunset version.


Getting started:

First off, make your midi. It's good to know ahead of time what tracks will serve what purpose. Remember that the combined total of all tracks can't exceed 16. I usually have between 5 - 8 main tracks and 1-2 for each of the special mixes. also make sure you have AudioRes/Seqs/seq.arc extracted, with all the bms files ready to replace. n_tutorial.bms is the Valley of Repose theme, Forest.bms is the Awakening Wood theme, yakushima.bms is the Perplexing Pool theme, and last.bms is the Wistful Wild theme.

Next, make the bms of your midi like you normally would with Flaaffy. The instruments and banks you choose with flaaffy don't matter. Make sure each track only loads an instrument and program once at the beginning of the track and never again. Get your bms and open it in HxD. Also open specifically the original last.bms in HxD. Regardless of what song your making, last.bms is the easiest to work with by far.

In last.bms, delete everytyhing after 0x04 90, leaving just the header. Now, in your flaaffy bms do a search for the first instance of a4 20 in the bms, and delete everything before that. It should be around 2 lines in. Now, cut and paste whats left of the flaaffy bms to the end of last.bms.


Staying Organized:

You will surely want a text file with notes to keep yourself orgranized, because things can get messy coming up. Look at figure 1 to see how I format mine. From now on a track of the flaaffy bms will be reffered to as a "note track" and the actual tracks of the bms are just "tracks". You'll want to write down the offset of every instrument youre using, the offset of every note track, and what track uses what note track and instrument. Using this will make the "track setting" step far easier.


Setting Loops:

Now that you have the base of your interactive bms, its time to set the looping for every track. First, go to 0x04 90. You should see A4 20. Remember the offset this a4 20 is at. Now search for the next a420 in the bms. Now you're at the start of the next note track. Before anything else, add padding 00s to move the a420 you just found to the start of a new line. It will simplify steps in the future. Look back a bit and you will see the last track's looping jump branch. In a standard flaaffy bms, it will be an offset to the start of the note track followed by a "E7". Replace this E7 with FF and change the offset right before it to the start of the previous a4 20 plus 0x6. For example. If a track has a a4 20 starting at 0x0d 90, the loop offset at the end should look like this, C8 00 00 0d 96. Continue to do this for every note track, search for a4 20, move it to the start of next line, change the loop offset to point to the a4 20 +6, change the E7 to FF. do this until you get to the final track. Make sure as you do this, take notes of the offset of every a4 20. The final line has to be 32 byte aligned, so add 00 padding if needed. You will see a A4 20


Setting Instruments:

Go to the top part of your bms. Specifically, jump to offset 0x 03 2b. You will see a C4, followed by 00 00 01 8E. This part shouldn't be touched, but the part after it is important. There should be a A4 20 XX A4 21 XX. The byte following a4 20 is the bank this instrument will use. The a4 21 is the program. Make sure you know what bank and programs can be used within the bms you are replacing. Also keep in mind these are hex values, so program 14 would be entered as A4 21 0e, not A4 21 14. Continue to look around for these a4 21s, and take notes on the program number and the offset to the C4 in the C4 00 00 01 8E before it. The instrument offset at 0x 04 53 specifically is strange because it sets a program twice, only the second one matters though.

Setting Tracks:

Now that you have the loops for all the note tracks set up, and all the instrument setting in place, its time to actually assign the note track offsets and instrument offsets for each track.


Final Touches: