http://forums.sonicretro.org/index.php?showtopic=26350
ValleyBell:
I was always a fan of this sound driver.
It doesn't just use the LFO to make a nice vibrato and has lots of great PCM drums, but it's the only driver used in chinese pirates which actually sounds good. (if not great sometimes)
Recently I startet ripping another pirate with this sound driver and got the idea of reverse engineering the sound format.
Now, here are my results:
Data East music format:
Code
Header
------
Size Description
4 Absolute ROM-Pointer to Track 1
4 Absolute ROM-Pointer to Track 2
4 Absolute ROM-Pointer to Track 3
4 Absolute ROM-Pointer to Track 4
4 Absolute ROM-Pointer to Track 5
4 Absolute ROM-Pointer to Track 6 (DAC)
6 Channel Assignment for tracks 1-6 (default: 00 01 02 04 05 06, later version only)
-> these values specify the 4 lower bits of the Key On/Off command (028)
changing these shuffles doesn't change the track's channel (only the key on/off channel),
so you better don't change it
-> a value of FF causes the driver to ignore the channel
Track Data
----------
The early sound driver used in Side Pocket has to additional bytes at the beginning of each track:
Code
Size Description
1 unknown
1 Channel Assignment of current track
... Commands
In later versions the track starts directly with the commands.
Code
Command Description
00-7F aa Note (7F = rest)
-> aa = length
80 aa Tempo (track 1 only)
-> aa = Tempo Value (00 = slow, FF = fast)
82 aa Instrument Change
-> aa = Instrument No. in Instrument Lib
83 aa Volume Change
-> aa = Volume (TL value)
86 aa Note Stop value (default 08)
-> when a note is started, a length-counter is set to the note's length and counts down
when this counter reaches a stop value that's adjusted by aa, the note is stopped
when the counter reaches 0, the next note is processed
-> aa = 08 makes stop value = 01 (always)
aa > 08 can make the stop value negative or 00, resulting in bending notes
aa < 08 make the stop value higher
stop_value = 1 + round(note_len * (08 - aa) / 8)
table from driver:
07 -> 07 of 30, 04 of 18, 03 of 0C, 06 of 24
06 -> 0D of 30, 07 of 18, 04 of 0C, 0A of 24
05 -> 13 of 30, 0A of 18, 06 of 0C, 0F of 24
04 -> 19 of 30, 0D of 18, 07 of 0C, 13 of 24
03 -> 1F of 30, 10 of 18, 09 of 0C, 18 of 24
87 ??
88 aa Loop Start (nested loops are possible)
-> aa = loop count (00 = infinite)
89 Loop End
8D aa ??
8E aa set LFO register (022) (track 1 only)
-> aa = LFO value (ored with 08)
8F ??
90 aa bb ??
91 ??
92 aa Panorama
-> aa = L/R mask
93 aa ??
94 aa ??
95 Track End
96 aa DAC Volume (track 6 only)
-> aa = Volume (00=loud, 03=low)
de2mid (with source, writing the tool took longer than reverse engineering the format, btw)
I didn't work on the unknown coordination flags yet, as I found them when testing de2mid.
Example call for de2mid:
de2mid BarverBattleSaga.bin l 0019868A 0x16
(extracts call songs from Barver Battle Saga, works only with the v1.00 translation patch)
Feedback and comments are welcome.
Update: updated tool to add full support for Side Pocket and added some more unknown flags
another example call: de2mid "Side Pocket (JU) [!].bin" le 30DDE