Note: This is currently WIP research so all information may not be correct.
Instrument Set Pointer Table
This table can be found at 0xBCC270 in the OoT Debug ROM. It begins with the number of instrument sets in the Audiobank file:
xxxx 0000 0000 0000 0000 0000 0000 0000
xxxx = number of instrument sets.
The rest of the data looks like:
xxxxxxxx yyyyyyyy zzzzzzzz nn aa bb cc
xxxxxxxx = Pointer to the start of the instrument set within the Audiobank file.
yyyyyyyy = Size of the instrument set in bytes.
zzzzzzzz = Instrument set type?
nn = Number of instruments to be read (can be less than total but not greater, does not include percussion).
aa/bb/cc = Flags of some sort, setting aa to 0x40 enables percussion, 0 disables it.
Instrument Set Format
Because they are used individually, all pointers in an instrument set are relative to the start of the instrument set, not the start of Audiobank.
At the start of each instrument set you will find an array of 32-bit pointers that point to entries for each instrument index. If percussion is used then its pointer will usually come first and be followed by 0x00000000.
Instrument Indexes
Percussion
Rather than pointing to an instrument index directly, percussion instruments point to an array of 32-bit pointers to instrument indexes in order to map different instruments to different notes. The format of these indexes looks like:
xxxxxxxx zzzzzzzz pppppppp yyyyyyyy
xxxxxxxx = Unknown.
zzzzzzzz = Pointer to unknown data structure.
pppppppp = Default sample pitch.
yyyyyyyy = Pointer to instrument properties.
Other Instruments
For other instruments the indexes appear differently:
xxxxxxxx yyyyyyyy [zzzzzzzz pppppppp]*
xxxxxxxx = Unknown.
yyyyyyyy = Pointer to instrument properties.
zzzzzzzz = Pointer to unknown data structure.
pppppppp = Default sample pitch.
Note that [zzzzzzzz pppppppp] appears three times but may just be zeroes. I'm not sure exactly how it is used if it appears more than once at the moment.
Instrument Properties
This data is pointed to by the instrument indexes, I'm not sure of its format at the moment:
aaaa xxxx bbbb yyyy zzzz uuuu vvvv wwww
All variables are unknowns but they affect the way the sample plays back. I haven't done enough testing to say for sure what they do.
Unknown Data Structure
Header
The header identifies the sample and points to two other structures:
xxyyyyyy zzzzzzzz aaaaaaaa bbbbbbbb
xx = Unknown.
yyyyyy = Size in bytes of sample.
zzzzzzzz = Pointer to sample location in Audiotable.
aaaaaaaa = Pointer to structure 2.
bbbbbbbb = Pointer to structure 1.
Structure 1
I have no idea what this data does, I haven't tried modifying it yet. It is 0x50 bytes long.
Structure 2
Same case as above. This structure is 0x30 bytes long.
Moving Instruments Between Sets
If you can identify which instrument is mapped to each index then you should be able to move any instrument into any set. You will need to copy its index and unknown data structure and paste these over an instrument in a set that you wish to replace, remembering to fix any pointers that need changing.
Moving Audiobank To Another Location
If you're moving the Audiobank file, you will need to fix its entry in the file table and the assembly code used to load instrument sets, which is at 0xB5A4C0 in the Debug ROM:
3C05 xxxx 24A5 yyyy
Or in assembly code:
LUI $A1,xxxx
ADDIU $A1,$A1,yyyy
xxxx = First half of address.
yyyy = Second half of address.
Remember that these numbers are signed so if yyyy is greater than 0x7FFF you need to add 1 to xxxx.