nmlgc / ssg

秋霜玉 / Shuusou Gyoku
MIT License
22 stars 5 forks source link

Add a way to define the MIDI flavor (GM/GS/XG) of the output device #10

Open nmlgc opened 2 years ago

nmlgc commented 2 years ago

All MIDIs start with a GS Reset SysEx message (F0 41 10 42 12 40 00 7F 00 41 F7). I have a Yamaha keyboard that puts itself into a GS-"compatible" mode upon receiving this message, which effectively disables its high-quality remapping for GM instruments and thus makes the music sound worse than you would typically expect for a standard MIDI file.

In GM mode, we would

Bonus points for also adding an XG mode, which translates any of the GS SysEx messages to XG ones on the fly. This would first require us to fix the SysEx bugs in the original MIDI files, though.

Depends on #34.

nmlgc commented 9 months ago

This will be necessary if we want to ever have a chance of removing the original game's 50 ms freeze after the GM System On message. In the first preview build for the SC-88Pro delivery, I claimed to have removed that issue, but I actually only replaced it with the different workaround of integrating the delay into the MIDI event timing. It was still there, and caused the MIDI file to play 50 ms later than the original game.

These are the underlying problems:

  1. Once BGM packs open the floodgates for mods, people will want to put any random MIDIs into this game that might not start with a GM System On message. Therefore, it's up to the game to send it in order to not carry over any effects from the previous track, and add the recommended delay before sending any other MIDI message – just like Shuusou Gyoku originally did.
  2. MIDI files and MIDI devices can differ in their GM/GS/XG flavor. No one stops you from playing a GS MIDI on a device that only supports GM, or an XG MIDI on a GS device. The MIDI might initialize itself properly for its intended synth (and that one alone), but the respective vendor-specific SysEx message might not be understood by a user's playback device, which means that we stilll require a separate GM System On just in case.
  3. It's also possible to target multiple devices within a single MIDI file by expressing all GS/XG-specific setup via SysEx. Any detection logic would therefore have to consider every SysEx message before the first note.

So we can only remove the freeze and keep the original game's timing for the two original Shuusou Gyoku soundtracks if the user promises to play them back on a GS device. This is the only case in which we can fully let the MIDI file handle the timing of its initialization messages.

(Obviously, all of this is a non-issue if you just use a BGM pack with waveform tracks.)