diff options
author | Simon Howard | 2014-05-06 22:03:00 -0400 |
---|---|---|
committer | Simon Howard | 2014-05-06 22:03:00 -0400 |
commit | b2e5952c454dd46b29ca6c64e742b4505c20d5b7 (patch) | |
tree | 2f4ff32106428e5b498e9490e4b8caf5934f1c47 | |
parent | f102dc1c7d5e83c59b87afaf16c16a64c89db0c5 (diff) | |
download | chocolate-doom-b2e5952c454dd46b29ca6c64e742b4505c20d5b7.tar.gz chocolate-doom-b2e5952c454dd46b29ca6c64e742b4505c20d5b7.tar.bz2 chocolate-doom-b2e5952c454dd46b29ca6c64e742b4505c20d5b7.zip |
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.
-rw-r--r-- | src/i_oplmusic.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index c07146a7..a2bc22d8 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -881,12 +881,21 @@ static void KeyOnEvent(opl_track_data_t *track, midi_event_t *event) 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. if (event->data.channel.channel == 9) |