changeset 218:c619c8b6f696

Fix arpeggio handling.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 07 Oct 2012 23:02:02 +0300
parents 9fa6a00b294c
children b4eb9b59fef3
files jssplr.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/jssplr.c	Sun Oct 07 21:45:24 2012 +0300
+++ b/jssplr.c	Sun Oct 07 23:02:02 2012 +0300
@@ -97,6 +97,8 @@
             // Frequency = Frequency = 8363*2^((6*12*16*4 - Period) / (12*16*4))
             chn->cfreq = chn->freq = 8363.0f * pow(2.0f, (4608.0f - (double) value) / 768.0f);
         }
+
+        JMPSETNDFLAGS(cdfNewFreq);
     }
 }
 
@@ -790,12 +792,14 @@
  */
 static void jmpDoArpeggio(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int paramY, int paramX)
 {
-    JSSInstrument *tempInst = chn->instrument;
+    JSSInstrument *inst = chn->instrument;
 
-    if (tempInst)
+    if (inst != NULL)
     {
         int tmp = chn->note;
-        if (tmp == jsetNotSet || tmp == jsetNoteOff) return;
+        if (tmp == jsetNotSet || tmp == jsetNoteOff)
+            return;
+
         switch (mp->tick & 3)
         {
             case 1:
@@ -805,7 +809,9 @@
                 tmp += paramY;
                 break;
         }
-        jmpCSetPitch(mp, chn, jmpGetPeriodFromNote(mp, tmp + tempInst->ERelNote, tempInst->EFineTune));
+
+        tmp = dmClamp(tmp + inst->ERelNote, 0, 119);
+        jmpCSetPitch(mp, chn, jmpGetPeriodFromNote(mp, tmp, inst->EFineTune));
     }
 }
 
@@ -1501,7 +1507,7 @@
             if (flags & cdfNewPitch)
                 jmpCSetPitch(mp, chn, chn->pitch);
                 
-            if (flags & (cdfNewPitch | cdfNewFreq))
+            if (flags & (cdfNewFreq | cdfNewPitch))
                 jvmSetFreq(mp->device, channel, chn->freq);
 
             if (flags & cdfNewPos)