comparison 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
comparison
equal deleted inserted replaced
138:459a1be2bd0f 139:111f3e4b57ad
13 DMFixedPoint tmpPos = chn->chPos, tmpVolume = chn->chVolume; 13 DMFixedPoint tmpPos = chn->chPos, tmpVolume = chn->chVolume;
14 JMIXER_ADDBUF_TYPE 14 JMIXER_ADDBUF_TYPE
15 *ap = addBuffer, 15 *ap = addBuffer,
16 *tr = chn->chPrevR, 16 *tr = chn->chPrevR,
17 *tl = chn->chPrevL; 17 *tl = chn->chPrevL;
18 int strideLength = 0; 18 int strideLength = 0, tmpVolumeD = chn->chVolumeD;;
19 19
20 JMIXER_SAMPLE_TYPE *sp = (JMIXER_SAMPLE_TYPE *) chn->chData; 20 JMIXER_SAMPLE_TYPE *sp = (JMIXER_SAMPLE_TYPE *) chn->chData;
21 21
22 JMIXER_INIT 22 JMIXER_INIT
23 23
24 while (strideLength < mixLength && JMIXER_ENDCOND) 24 while (strideLength < mixLength && JMIXER_ENDCOND)
25 { 25 {
26 JMIXER_FUNC 26 JMIXER_FUNC
27 JMIXER_DEBUG 27 JMIXER_DEBUG
28 JMIXER_NEXT 28 JMIXER_NEXT
29 FP_ADD(tmpVolume, tmpDeltaV); 29 if (tmpVolumeD)
30 {
31 tmpVolumeD--;
32 FP_ADD(tmpVolume, tmpDeltaV);
33 }
30 strideLength++; 34 strideLength++;
31 } 35 }
32 36
33 chn->chPos = tmpPos; 37 chn->chPos = tmpPos;
34 chn->chVolume = tmpVolume; 38 chn->chVolume = tmpVolume;
39 chn->chVolumeD = tmpVolumeD;
35 return strideLength; 40 return strideLength;
36 } 41 }
37 #endif 42 #endif
38 43
39 #undef JMIXER_NAME 44 #undef JMIXER_NAME