Mercurial > hg > dmlib
annotate minijss/jmix_c_in.c @ 1315:7687412f9aef
Fix jssmod sample conversion flags storing .. urgh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Aug 2017 01:54:54 +0300 |
parents | b52905e2788e |
children | 95eb6285f45c |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Mixing routines in C | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
1193 | 4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
7 //#define JMIXER_DEBUG fprintf(stderr, "[%.8x:%.8x / %.8x]: %d\n", FP_GETH32(tmpPos), FP_GETL32(tmpPos), endPos, sp[FP_GETH32(tmpPos)]); |
0 | 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 |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
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 \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
17 const Sint32 vol = (FP_GETH32(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])); \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
19 tl[4] = (((Sint32) sp[FP_GETH32(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); |
1189 | 23 #define JMIXER_NEXT_RAMP FP_ADD(tmpPos, tmpDelta); FP_ADD(tmpVolume, tmpDeltaV); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
24 #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
|
25 #include "jmixtmpl_c.h" |
0 | 26 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
27 #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
|
28 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
1189 | 29 #define JMIXER_NEXT_RAMP FP_SUB(tmpPos, tmpDelta); FP_ADD(tmpVolume, tmpDeltaV); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
30 #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
|
31 #include "jmixtmpl_c.h" |
0 | 32 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
33 |
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_SAMPLE_TYPE |
0 | 35 #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
|
36 #undef JMIXER_FUNC |
0 | 37 |
56
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
38 |
0 | 39 /* Stereo / Linear Interpolation |
40 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
41 #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
|
42 #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
|
43 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
44 #define JMIXER_FUNC \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
45 const Sint32 vol_l = (FP_GETH32(tmpVolume) * mixer->globalVol) / 256, \ |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
46 vol_r = (FP_GETH32(tmpVolume) * mixer->globalVol) / 256; \ |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
47 memmove(&tl[0], &tl[1], 4 * sizeof(tl[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
48 memmove(&tr[0], &tr[1], 4 * sizeof(tr[0])); \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
49 tl[4] = (((Sint32) sp[FP_GETH32(tmpPos)]) * vol_l * 3 + tl[3] * 2 + tl[2] + tl[1] + tl[0]) / (256 * 8); *(ap++) += tl[4]; \ |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
50 tr[4] = (((Sint32) sp[FP_GETH32(tmpPos)]) * vol_r * 3 + tr[3] * 2 + tr[2] + tr[1] + tr[0]) / (256 * 8); *(ap++) += tr[4]; |
0 | 51 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
52 #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
|
53 #define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); |
1189 | 54 #define JMIXER_NEXT_RAMP FP_ADD(tmpPos, tmpDelta); FP_ADD(tmpVolume, tmpDeltaV); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
55 #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
|
56 #include "jmixtmpl_c.h" |
0 | 57 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
58 #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
|
59 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
1189 | 60 #define JMIXER_NEXT_RAMP FP_SUB(tmpPos, tmpDelta); FP_ADD(tmpVolume, tmpDeltaV); |
287
1e89cd081956
Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
61 #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
|
62 #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
|
63 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
64 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
65 #undef JMIXER_SAMPLE_TYPE |
0 | 66 #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
|
67 #undef JMIXER_FUNC |
0 | 68 |
69 | |
70 /* Post processing functions | |
71 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
72 #define JMIXER_CLAMP \ |
0 | 73 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
|
74 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
|
75 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
76 #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
|
77 #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
|
78 #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
|
79 #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
|
80 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
81 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
82 #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
|
83 #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
|
84 #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
|
85 #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
|
86 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
87 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
88 #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
|
89 #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
|
90 #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
|
91 #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
|
92 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
93 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
94 #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
|
95 #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
|
96 #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
|
97 #include "jmix_post_c.h" |