shithub: choc

Download patch

ref: c887c9804b07ffc2d56fc4ab31ed1aa1486fd5c4
parent: 01cebf1373d482f3dca1eb9706a6b85595e83ea1
author: Simon Howard <fraggle@gmail.com>
date: Sun Aug 30 19:55:43 EDT 2009

Use fixed note on instruments with the fixed note flag set.

Subversion-branch: /branches/opl-branch
Subversion-revision: 1649

--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -48,7 +48,7 @@
 #define GENMIDI_NUM_INSTRS  128
 
 #define GENMIDI_HEADER          "#OPL_II#"
-#define GENMIDI_FLAG_FIXED      0x0000         /* fixed pitch */
+#define GENMIDI_FLAG_FIXED      0x0001         /* fixed pitch */
 #define GENMIDI_FLAG_2VOICE     0x0002         /* double voice (OPL3) */
 
 typedef struct
@@ -701,6 +701,9 @@
         return;
     }
 
+    voice->channel = channel;
+    voice->note = note;
+
     // Program the voice with the instrument data:
 
     SetVoiceInstrument(voice, &instrument->opl2_voice);
@@ -710,14 +713,16 @@
     WriteRegister(OPL_REGS_LEVEL + voice->op2,
                   volume_mapping_table[volume]);
 
-    // Play the note.
+    // Fixed pitch?
 
-    voice->channel = channel;
-    voice->note = note;
+    if ((instrument->flags & GENMIDI_FLAG_FIXED) != 0)
+    {
+        note = instrument->fixed_note;
+    }
 
     // Write the frequency value to turn the note on.
 
-    voice->freq = FrequencyForNote(voice->note);
+    voice->freq = FrequencyForNote(note);
 
     WriteRegister(OPL_REGS_FREQ_1 + voice->index, voice->freq & 0xff);
     WriteRegister(OPL_REGS_FREQ_2 + voice->index, (voice->freq >> 8) | 0x20);