ref: b2e5952c454dd46b29ca6c64e742b4505c20d5b7
parent: f102dc1c7d5e83c59b87afaf16c16a64c89db0c5
author: Simon Howard <[email protected]>
date: Tue May 6 18:03:00 EDT 2014
oplmusic: Handle key-on with volume 0 as key-off. Some MIDI files, such as the music tracks in AV.wad, use a second "key on" event with a volume of zero to mean "key off". Handle this case correctly.
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -881,11 +881,20 @@
event->data.channel.param2);
*/
- // The channel.
-
- channel = &track->channels[event->data.channel.channel];
key = event->data.channel.param1;
volume = event->data.channel.param2;
+
+ // A volume of zero means key off. Some MIDI tracks, eg. the ones
+ // in AV.wad, use a second key on with a volume of zero to mean
+ // key off.
+ if (volume <= 0)
+ {
+ KeyOffEvent(track, event);
+ return;
+ }
+
+ // The channel.
+ channel = &track->channels[event->data.channel.channel];
// Percussion channel (10) is treated differently.