-
Notifications
You must be signed in to change notification settings - Fork 24
Bank Editing
Instruments in N64 games are organized into banks (also called instrument sets). Each bank contains the metadata (but not the raw sample data) for a set of instruments, which will be used together for one or more sequences. If you're importing a MIDI and there's an existing bank which contains all the instruments you need, just assign them to your channels using MIDI program change commands (the program numbers have to match the index of the instruments in the bank, not General MIDI program numbers). However, often your MIDI requires instruments from multiple original banks in the game. SEQ64 allows you to create a new bank combining these instruments, and also edit existing banks in the ROM.
Banks contain three different kinds of sounds: instruments, drums, and SFX. (I have not yet found any games which use the SFX category [in-game sound effects are usually implemented as instruments in the zeroth bank], but the bank format supports it so SEQ64 does as well.) Drums get played on channel 9 (10 counting from 1) and usually contain up to 0x40 drums, most of which are repitched versions of other drums.
- Load your ROM and RomDesc.
- In the Known Files box, click on Audiobank Index. Select the bank whose instruments are closest to the ones you want in your sequence. To quickly see what instruments are contained in what banks (without separately loading each one), go to the Audiobank tab and click on the banks in the Audiobank Library section.
- Click Load Bank and switch to the Audiobank tab.
- The box on the left side of the Loaded Bank section shows the "folder structure" of the bank. Double-click on an entry (or click on it and click Open) to open it. The path above shows your position in the hierarchy. Fields which cannot be opened have actual values to them, which you can edit in the box to the right.
- If the currently opened item is a list of items (e.g. /instruments/), you can add, duplicate, delete, and move up and down the currently selected item in the list. You can also edit the name of the item. The names of items (e.g. in /samples/ or /aladpcmbooks/) which don't have a name defined in the RomDesc get automatically generated names based on the instruments which refer to them, so you can see approximately what they are without having to manually assign names to them.
- The most important data structure is /abbank/instlist/, which contains pointers to the actual instruments (stored in /instruments/), in slots corresponding to MIDI program number. After you've imported instruments, make sure to set the values in this data structure to point to the correct instruments. You can have two slots (program numbers) pointing to the same instrument, and you can have a slot with a value of -1 not pointing to any instrument. Nintendo seems to typically have program numbers and channel numbers mapped 1:1, so channel 0 plays program 0, etc., and therefore also since channel 9 plays drums, program 9 is nullptr. But it will work fine if you put the instruments in any slots, and you can use program changes to have any channel play any of them.
- /abdrumlist/drumlist/ and /absfxlist/sfxlist/ correspond to /abbank/instlist/ for drums and SFX, though I haven't actually done any editing of drum sets, and again I haven't seen any SFX.
- /patchprops/ are actually envelope control values; when I was developing SEQ64 at first I was using outdated documentation which didn't know this, so that's why it's not called envelope. You can see that often envelopes are shared by multiple instruments. Release rate is NOT stored in here, it's the field called "decaytime" in the instrument itself.
- The tuning field in ABSound (e.g. /instruments/7. Tuba/splits/ABSound /) is actually a 32-bit floating point number, not a uint32. SEQ64 doesn't know how to deal with it natively yet, but you can use an online floating point number tool to convert to and from the hex representation.
- The three items in splits correspond to the sound for the lower part, the middle part, and the upper part of the keyboard, with the boundaries defined by splitpoint1 and splitpoint2.
- Each sample has a corresponding ALADPCMLoop and ALADPCMBook object--they need to be there and the right sample has to be pointing to the right one.
- VERY IMPORTANT: When SEQ64 parses a bank, it instantiates items in lists based on the order they appear, i.e. the order other things point to them. So, let's say you have two instruments, Piano and Ocarina, in /instruments/, and then in /abbank/instlist/ you have the 0th slot pointing to Piano (instrument 1) and the first slot pointing to Ocarina (instrument 0). To be clear, this is a totally valid configuration and will work fine in-game. HOWEVER, if this bank is saved back to the ROM and loaded again, when it's loaded SEQ64 will see the pointer to Piano first and therefore make Piano be instrument 0, and then Ocarina be instrument 1. But the LABELS for what the instruments are are stored by index in each list, so since when you saved it Ocarina was instrument 0, instrument 0 (now Piano) will be labeled Ocarina, and vice versa. Again, the bank itself is not corrupted (you can edit it and save it back and it will work fine), just the names will be wrong and this will cause confusion if you're trying to edit it later. The solution is that, when you're all done editing the bank, before you save it back, go through each list (/instruments/, /drums/, /sfx/, /patchprops/, /samples/, /aladpcmbooks/, /aladpcmloops/) and reorder the items until they're in the order which they will be pointed to. For instance, make /instruments/ be in the same order that /abbank/instlist/ points to those instruments, and then make /samples/, /aladpcmbooks/, and /aladpcmloops/ be in that same order (since the entries in /instruments/ point to entries in /samples/, and /samples/ point to /aladpcmbooks/ and /aladpcmloops/).
Keeping all that in mind, the actual process for creating your bank is quite simple.
- Open /instruments/ and delete any instruments you won't need. Then go through /samples/, /aladpcmbooks/, and /aladpcmloops/ and delete the corresponding data used by those instruments you deleted. After you're done deleting, also check /patchprops/ in case there are some only used by the instruments you deleted.
- In the Audiobank Library section, go through the banks until you find one that has the instrument you want, select the instrument, and click Add to Loaded Inst Set. Not only will its entry in /instruments/ be added, but its patchprops, samples, aladpcmbooks, and aladpcmloops will be added as well.
- Edit /abbank/instlist/ to make a pointer to your new instrument at the desired slot.
- Reorder the instrument's data in all the lists so that it will be loaded in the correct order compared to the other instruments in /abbank/instlist/ (as described above about the RomDesc names).
- [Manual editing of sample addresses no longer required--this is done automatically at instrument import.]
- Once you're satisfied with the bank and sure everything's in the right order so the names don't get scrambled, go back to the Files tab and click Save Bank while the desired bank you want to replace is selected. Save the ROM, and also click RomDesc->Save As and make a new RomDesc to track your modifications to the bank. I suggest you also rename the bank itself on the Files tab so you don't forget which one you messed with.