Mercurial > hg > dmlib
annotate jmix_c_in.c @ 300:4972ca91d062
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 11 Oct 2012 17:55:15 +0300 |
parents | 1e89cd081956 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Mixing routines in C | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2006-2007 Tecnic Software productions (TNSP) | |
5 */ | |
6 | |
7 //#define JMIXER_DEBUG fprintf(stderr, "[%.8x:%.8x / %.8x]: %d\n", FP_GETH(tmpPos), FP_GETL(tmpPos), endPos, sp[FP_GETH(tmpPos)]); | |
8 #define JMIXER_DEBUG | |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
9 #define JMIXER_ADDBUF_TYPE Sint32 |
0 | 10 |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
11 |
0 | 12 /* Mono / Linear Interpolation |
13 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
14 #define JMIXER_SAMPLE_TYPE Sint16 |
134
1ba202b448e0
Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
15 #define JMIXER_INIT |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
16 #define JMIXER_FUNC \ |
134
1ba202b448e0
Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
17 const Sint32 vol = (FP_GETH(tmpVolume) * mixer->globalVol) / 256; \ |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
18 memmove(&tl[0], &tl[1], 4 * sizeof(tl[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
19 tl[4] = (((Sint32) sp[FP_GETH(tmpPos)]) * vol * 3 + tl[3] * 2 + tl[2] + tl[1] + tl[0]) / (256 * 8); *(ap++) += tl[4]; \ |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
20 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
21 #define JMIXER_NAME jvmMix_Mono_C_FW |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
22 #define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
23 #define JMIXER_ENDCOND (tmpPos.dw < endPos.dw) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
24 #include "jmixtmpl_c.h" |
0 | 25 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
26 #define JMIXER_NAME jvmMix_Mono_C_BW |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
27 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
28 #define JMIXER_ENDCOND (tmpPos.dw > endPos.dw) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
29 #include "jmixtmpl_c.h" |
0 | 30 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
31 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
32 #undef JMIXER_SAMPLE_TYPE |
0 | 33 #undef JMIXER_INIT |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
34 #undef JMIXER_FUNC |
0 | 35 |
56
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
36 |
0 | 37 /* Stereo / Linear Interpolation |
38 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
39 #define JMIXER_SAMPLE_TYPE Sint16 |
134
1ba202b448e0
Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
40 #define JMIXER_INIT |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
41 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
42 #define JMIXER_FUNC \ |
134
1ba202b448e0
Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
43 const Sint32 vol_l = (FP_GETH(tmpVolume) * mixer->globalVol) / 256, \ |
1ba202b448e0
Implement volume and panning ramps (interpolation between callbacks aka "frames")
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
44 vol_r = (FP_GETH(tmpVolume) * mixer->globalVol) / 256; \ |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
45 memmove(&tl[0], &tl[1], 4 * sizeof(tl[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
46 memmove(&tr[0], &tr[1], 4 * sizeof(tr[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
47 tl[4] = (((Sint32) sp[FP_GETH(tmpPos)]) * vol_l * 3 + tl[3] * 2 + tl[2] + tl[1] + tl[0]) / (256 * 8); *(ap++) += tl[4]; \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
48 tr[4] = (((Sint32) sp[FP_GETH(tmpPos)]) * vol_r * 3 + tr[3] * 2 + tr[2] + tr[1] + tr[0]) / (256 * 8); *(ap++) += tr[4]; |
0 | 49 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
50 #define JMIXER_NAME jvmMix_Stereo_C_FW |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
51 #define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
52 #define JMIXER_ENDCOND (tmpPos.dw < endPos.dw) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
53 #include "jmixtmpl_c.h" |
0 | 54 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
55 #define JMIXER_NAME jvmMix_Stereo_C_BW |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
56 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
57 #define JMIXER_ENDCOND (tmpPos.dw > endPos.dw) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
58 #include "jmixtmpl_c.h" |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
59 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
60 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
61 #undef JMIXER_SAMPLE_TYPE |
0 | 62 #undef JMIXER_INIT |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
63 #undef JMIXER_FUNC |
0 | 64 |
65 | |
66 /* Post processing functions | |
67 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
68 #define JMIXER_CLAMP \ |
0 | 69 if (t < JVM_LIMIT_16_NEG) t = JVM_LIMIT_16_NEG; else \ |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
70 if (t > JVM_LIMIT_16_POS) t = JVM_LIMIT_16_POS; |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
71 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
72 #define JMIXER_NAME jvmPostProcess_U8_C |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
73 #define JMIXER_TYPE Uint8 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
74 #define JMIXER_FUNCTION *(sp++) = (t + JVM_ADD_16) >> 8; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
75 #include "jmix_post_c.h" |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
76 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
77 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
78 #define JMIXER_NAME jvmPostProcess_S8_C |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
79 #define JMIXER_TYPE Sint8 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
80 #define JMIXER_FUNCTION *(sp++) = t >> 8; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
81 #include "jmix_post_c.h" |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
82 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
83 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
84 #define JMIXER_NAME jvmPostProcess_U16_C |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
85 #define JMIXER_TYPE Uint16 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
86 #define JMIXER_FUNCTION *(sp++) = t + JVM_ADD_16; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
87 #include "jmix_post_c.h" |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
88 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
89 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
90 #define JMIXER_NAME jvmPostProcess_S16_C |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
91 #define JMIXER_TYPE Sint16 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
92 #define JMIXER_FUNCTION *(sp++) = t; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
93 #include "jmix_post_c.h" |