diff jmixtmpl_c.h @ 139:111f3e4b57ad

Improve volume ramping functionality to allow arbitrary length ramps.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 05 Oct 2012 09:25:59 +0300
parents 1ba202b448e0
children 301de8c0cd01
line wrap: on
line diff
--- a/jmixtmpl_c.h	Fri Oct 05 05:43:17 2012 +0300
+++ b/jmixtmpl_c.h	Fri Oct 05 09:25:59 2012 +0300
@@ -15,7 +15,7 @@
         *ap = addBuffer,
         *tr = chn->chPrevR,
         *tl = chn->chPrevL;
-    int strideLength = 0;
+    int strideLength = 0, tmpVolumeD = chn->chVolumeD;;
 
     JMIXER_SAMPLE_TYPE *sp = (JMIXER_SAMPLE_TYPE *) chn->chData;
 
@@ -26,12 +26,17 @@
         JMIXER_FUNC
         JMIXER_DEBUG
         JMIXER_NEXT
-        FP_ADD(tmpVolume, tmpDeltaV);
+        if (tmpVolumeD)
+        {
+            tmpVolumeD--;
+            FP_ADD(tmpVolume, tmpDeltaV);
+        }
         strideLength++;
     }
 
     chn->chPos = tmpPos;
     chn->chVolume = tmpVolume;
+    chn->chVolumeD = tmpVolumeD;
     return strideLength;
 }
 #endif