shithub: choc

Download patch

ref: 5a7a5402f74361dee7f2c6109eb46b83b4d17c16
parent: 5e064562c09ceb5b93a4ddafe734cdb6c7b081c6
parent: cad5d6f20172bb441a75309d8db38f0c910aaa44
author: Simon Howard <fraggle+github@gmail.com>
date: Tue Oct 28 18:27:36 EDT 2014

Merge pull request #467 from khokh2001/opl-fix3

Use MIDI note number 60 for percussion instruments, unless overridden
by the fixed_note field in the GENMIDI lump.

--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -812,6 +812,7 @@
 static void VoiceKeyOn(opl_channel_data_t *channel,
                        genmidi_instr_t *instrument,
                        unsigned int instrument_voice,
+                       unsigned int note,
                        unsigned int key,
                        unsigned int volume)
 {
@@ -850,7 +851,7 @@
     }
     else
     {
-        voice->note = key;
+        voice->note = note;
     }
 
     // Program the voice with the instrument data:
@@ -871,6 +872,7 @@
 {
     genmidi_instr_t *instrument;
     opl_channel_data_t *channel;
+    unsigned int note;
     unsigned int key;
     unsigned int volume;
 
@@ -881,6 +883,7 @@
            event->data.channel.param2);
 */
 
+    note = event->data.channel.param1;
     key = event->data.channel.param1;
     volume = event->data.channel.param2;
 
@@ -909,6 +912,7 @@
 
         last_perc[last_perc_count] = key;
         last_perc_count = (last_perc_count + 1) % PERCUSSION_LOG_LEN;
+        note = 60;
     }
     else
     {
@@ -918,11 +922,11 @@
     // Find and program a voice for this instrument.  If this
     // is a double voice instrument, we must do this twice.
 
-    VoiceKeyOn(channel, instrument, 0, key, volume);
+    VoiceKeyOn(channel, instrument, 0, note, key, volume);
 
     if ((SHORT(instrument->flags) & GENMIDI_FLAG_2VOICE) != 0)
     {
-        VoiceKeyOn(channel, instrument, 1, key, volume);
+        VoiceKeyOn(channel, instrument, 1, note, key, volume);
     }
 }