Mercurial > hg > dmlib
annotate jmix_c_in.c @ 100:f16d102dbbac
Add a function for setting bitmapped font palette.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 20:33:01 +0300 |
parents | 2edda27f951c |
children | 1ba202b448e0 |
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 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
15 #define JMIXER_INIT const Sint32 vol = (chn->chVolume * mixer->globalVol) / 256; |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
16 #define JMIXER_FUNC \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
17 memmove(&tl[0], &tl[1], 4 * sizeof(tl[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
18 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
|
19 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
20 #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
|
21 #define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
22 #define JMIXER_ENDCOND (FP_GETH(tmpPos) < endPos) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
23 #include "jmixtmpl_c.h" |
0 | 24 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
25 #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
|
26 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
27 #define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
28 #include "jmixtmpl_c.h" |
0 | 29 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
30 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
31 #undef JMIXER_SAMPLE_TYPE |
0 | 32 #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
|
33 #undef JMIXER_FUNC |
0 | 34 |
56
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
35 |
0 | 36 /* Stereo / Linear Interpolation |
37 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
38 #define JMIXER_SAMPLE_TYPE Sint16 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
39 #define JMIXER_INIT const Sint32 vol_l = (chn->chVolume * mixer->globalVol) / 256, \ |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
40 vol_r = (chn->chVolume * mixer->globalVol) / 256; |
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 \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
43 memmove(&tl[0], &tl[1], 4 * sizeof(tl[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
44 memmove(&tr[0], &tr[1], 4 * sizeof(tr[0])); \ |
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
45 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
|
46 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 | 47 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
48 #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
|
49 #define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
50 #define JMIXER_ENDCOND (FP_GETH(tmpPos) < endPos) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
51 #include "jmixtmpl_c.h" |
0 | 52 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
53 #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
|
54 #define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
55 #define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) |
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" |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
57 |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
58 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
59 #undef JMIXER_SAMPLE_TYPE |
0 | 60 #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
|
61 #undef JMIXER_FUNC |
0 | 62 |
63 | |
64 /* Post processing functions | |
65 */ | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
66 #define JMIXER_CLAMP \ |
0 | 67 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
|
68 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
|
69 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
70 #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
|
71 #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
|
72 #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
|
73 #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
|
74 |
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_S8_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 Sint8 |
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 >> 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_U16_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 Uint16 |
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 + JVM_ADD_16; |
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_S16_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 Sint16 |
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; |
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" |