annotate minijss/jmixtmpl_c.h @ 2298:b5abfff07ca9

Add new DMGrowBuf helper functions dmGrowBufCopyOffsSize() and dmGrowBufConstCopyOffsSize().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 04 Jul 2019 10:54:16 +0300
parents b52905e2788e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * miniJSS - Mixing routine in C, innerloop template
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
1193
b52905e2788e Bump copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 1189
diff changeset
4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 */
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
287
1e89cd081956 Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
7 int JMIXER_NAME (JSSMixer *mixer, JSSChannel *chn, JMIXER_ADDBUF_TYPE *addBuffer, const int mixLength, const DMFixedPoint endPos)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifdef JMIXER_HEADER
233
e3c1aa3ba88e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
9 ;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #else
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 {
134
1ba202b448e0 Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
12 const DMFixedPoint tmpDelta = chn->chDeltaO, tmpDeltaV = chn->chDeltaV;
319
37382bee0619 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
13 DMFixedPoint tmpPos = chn->chPos,
37382bee0619 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
14 tmpVolume = chn->chVolume;
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
15 JMIXER_ADDBUF_TYPE
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
16 *ap = addBuffer,
57
2edda27f951c Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
17 *tr = chn->chPrevR,
2edda27f951c Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
18 *tl = chn->chPrevL;
230
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
19 int strideLength = 0;
759
d7bd9c11229e Silence some warnings.
Matti Hamalainen <ccr@tnsp.org>
parents: 658
diff changeset
20 (void) tr;
d7bd9c11229e Silence some warnings.
Matti Hamalainen <ccr@tnsp.org>
parents: 658
diff changeset
21 (void) tl;
57
2edda27f951c Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
22
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
23 JMIXER_SAMPLE_TYPE *sp = (JMIXER_SAMPLE_TYPE *) chn->chData;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
25 JMIXER_INIT
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
26
230
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
27 if (chn->chVolumeD > 0)
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
28 {
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
29 const int tmpLength = chn->chVolumeD < mixLength ? chn->chVolumeD : mixLength;
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
30 chn->chVolumeD -= tmpLength;
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
31
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
32 while (strideLength < tmpLength && JMIXER_ENDCOND)
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
33 {
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
34 JMIXER_FUNC
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
35 JMIXER_DEBUG
1189
bd2615822bbf Adjust mixing macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 1127
diff changeset
36 JMIXER_NEXT_RAMP
230
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
37 strideLength++;
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
38 }
585e0a95be36 Optimize mixing slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 229
diff changeset
39 }
1127
e22d4ceb6414 Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 759
diff changeset
40
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
41 while (strideLength < mixLength && JMIXER_ENDCOND)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 {
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
43 JMIXER_FUNC
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
44 JMIXER_DEBUG
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
45 JMIXER_NEXT
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
46 strideLength++;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
134
1ba202b448e0 Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
49 chn->chPos = tmpPos;
1ba202b448e0 Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
50 chn->chVolume = tmpVolume;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 return strideLength;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 }
35
fb5200deeda8 Another fix, related to 7908061da010.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
53 #endif
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
55 #undef JMIXER_NAME
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
56 #undef JMIXER_NEXT
1189
bd2615822bbf Adjust mixing macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 1127
diff changeset
57 #undef JMIXER_NEXT_RAMP
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 #undef JMIXER_ENDCOND
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
59