# HG changeset patch # User Matti Hamalainen # Date 1349063940 -10800 # Node ID 8725853609db8e829fb891d2a447a1f22205265e # Parent e0e470c3fc8eb9427d64060ca3171a7685f30373 Remove the floating point mixing .. it wasn't so good idea after all. diff -r e0e470c3fc8e -r 8725853609db jmix_c_in.c --- a/jmix_c_in.c Mon Oct 01 06:28:29 2012 +0300 +++ b/jmix_c_in.c Mon Oct 01 06:59:00 2012 +0300 @@ -7,35 +7,10 @@ //#define JMIXER_DEBUG fprintf(stderr, "[%.8x:%.8x / %.8x]: %d\n", FP_GETH(tmpPos), FP_GETL(tmpPos), endPos, sp[FP_GETH(tmpPos)]); #define JMIXER_DEBUG -#ifndef JMIXER_ADDBUF_TYPE -#ifdef JSS_MIX_FP -#define JMIXER_ADDBUF_TYPE double -#else #define JMIXER_ADDBUF_TYPE Sint32 -#endif -#endif /* Mono / Linear Interpolation */ -#ifdef JSS_MIX_FP -#define JMIXER_SAMPLE_TYPE float -#define JMIXER_INIT const float vol = (float) (chn->chVolume * mixer->globalVol) / (256.0f * 64.0f); -#define JMIXER_FUNC tr = (sp[FP_GETH(tmpPos)] * vol + tr) / 2.0f; *(ap++) += tr; - - -#define JMIXER_NAME jvmMix_Mono_C_FW -#define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); -#define JMIXER_ENDCOND (FP_GETH(tmpPos) < endPos) -#include "jmixtmpl_c.h" - - -#define JMIXER_NAME jvmMix_Mono_C_BW -#define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); -#define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) -#include "jmixtmpl_c.h" - -#else - #define JMIXER_ADDBUF_TYPE Sint32 #define JMIXER_SAMPLE_TYPE Sint16 #define JMIXER_INIT const Sint32 vol = (chn->chVolume * mixer->globalVol) / 256; @@ -51,34 +26,13 @@ #define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) #include "jmixtmpl_c.h" -#endif - #undef JMIXER_SAMPLE_TYPE #undef JMIXER_INIT #undef JMIXER_FUNC + /* Stereo / Linear Interpolation */ -#ifdef JSS_MIX_FP -#define JMIXER_SAMPLE_TYPE float -#define JMIXER_INIT const double vol_l = (chn->chVolume * mixer->globalVol) / 256.0f, \ - vol_r = (chn->chVolume * mixer->globalVol) / 256.0f; - -#define JMIXER_FUNC tl = ((double)sp[FP_GETH(tmpPos)] * vol_l + tl) / (2.0f * 256.0f); *(ap++) += tl; \ - tr = ((double)sp[FP_GETH(tmpPos)] * vol_r + tr) / (2.0f * 256.0f); *(ap++) += tr; - -#define JMIXER_NAME jvmMix_Stereo_C_FW -#define JMIXER_NEXT FP_ADD(tmpPos, tmpDelta); -#define JMIXER_ENDCOND (FP_GETH(tmpPos) < endPos) -#include "jmixtmpl_c.h" - -#define JMIXER_NAME jvmMix_Stereo_C_BW -#define JMIXER_NEXT FP_SUB(tmpPos, tmpDelta); -#define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) -#include "jmixtmpl_c.h" - -#else - #define JMIXER_SAMPLE_TYPE Sint16 #define JMIXER_INIT const Sint32 vol_l = (chn->chVolume * mixer->globalVol) / 256, \ vol_r = (chn->chVolume * mixer->globalVol) / 256; @@ -96,8 +50,6 @@ #define JMIXER_ENDCOND (FP_GETH(tmpPos) > endPos) #include "jmixtmpl_c.h" -#endif - #undef JMIXER_SAMPLE_TYPE #undef JMIXER_INIT #undef JMIXER_FUNC @@ -105,38 +57,6 @@ /* Post processing functions */ -#ifdef JSS_MIX_FP - -#define JMIXER_CLAMP \ - if (t < -1.0f) t = -1.0f; else \ - if (t > 1.0f) t = 1.0f; - -#define JMIXER_NAME jvmPostProcess_U8_C -#define JMIXER_TYPE Uint8 -#define JMIXER_FUNCTION *(sp++) = (t + 1.0f) * 127.0f; -#include "jmix_post_c.h" - - -#define JMIXER_NAME jvmPostProcess_S8_C -#define JMIXER_TYPE Sint8 -#define JMIXER_FUNCTION *(sp++) = t * 127.0f; -#include "jmix_post_c.h" - - -#define JMIXER_NAME jvmPostProcess_U16_C -#define JMIXER_TYPE Uint16 -#define JMIXER_FUNCTION *(sp++) = (t + 1.0f) * 32767.0f; -#include "jmix_post_c.h" - - -#define JMIXER_NAME jvmPostProcess_S16_C -#define JMIXER_TYPE Sint16 -#define JMIXER_FUNCTION *(sp++) = t * 32767.0f; -#include "jmix_post_c.h" - - -#else - #define JMIXER_CLAMP \ if (t < JVM_LIMIT_16_NEG) t = JVM_LIMIT_16_NEG; else \ if (t > JVM_LIMIT_16_POS) t = JVM_LIMIT_16_POS; @@ -163,5 +83,3 @@ #define JMIXER_TYPE Sint16 #define JMIXER_FUNCTION *(sp++) = t; #include "jmix_post_c.h" - -#endif diff -r e0e470c3fc8e -r 8725853609db jss.h --- a/jss.h Mon Oct 01 06:28:29 2012 +0300 +++ b/jss.h Mon Oct 01 06:59:00 2012 +0300 @@ -31,7 +31,6 @@ #define jsfLooped (0x01) // Is sample looped #define jsfBiDi (0x02) // Bi-directional loop? #define jsf16bit (0x04) // 16-bit? -#define jsfFP (0x08) // Floating point sample #define JSFSET(a, b) do { a |= b; } while (0) #define JSFUNSET(a, b) do { a &= (0xff ^ b); } while (0) diff -r e0e470c3fc8e -r 8725853609db jssmix.h --- a/jssmix.h Mon Oct 01 06:28:29 2012 +0300 +++ b/jssmix.h Mon Oct 01 06:59:00 2012 +0300 @@ -11,18 +11,13 @@ #define DBG(...) do { /* stub */ } while (0) -#ifdef JSS_MIX_FP -#define JMIXER_ADDBUF_TYPE double -#else -#define JMIXER_ADDBUF_TYPE Sint32 -#endif - - // Mixing limits #define JVM_LIMIT_16_POS (32767) #define JVM_LIMIT_16_NEG (-32767) #define JVM_ADD_16 (32768) +#define JMIXER_ADDBUF_TYPE Sint32 + // A channel data structure typedef struct diff -r e0e470c3fc8e -r 8725853609db jssmod.c --- a/jssmod.c Mon Oct 01 06:28:29 2012 +0300 +++ b/jssmod.c Mon Oct 01 06:59:00 2012 +0300 @@ -197,39 +197,6 @@ return TRUE; } -#ifdef JSS_MIX_FP -/* Convert sample data from S16 or U8 to floating point - */ -int jssConvertSampleToFP(void **dst, void * src, const size_t len, const int flags) -{ - size_t count = len; - float *out; - - *dst = out = dmMalloc(sizeof(float) * len); - if (out == NULL) - return DMERR_MALLOC; - - if (flags & jsf16bit) - { - Sint16 *in = (Sint16 *) src; - while (count--) - { - *(out++) = (float) (*(in++)) / 32768.0f; - } - } - else - { - Uint8 *in = (Uint8 *) src; - while (count--) - { - *(out++) = ((float) *(in++) - 128.0f) / 56.0f; - } - } - - return DMERR_OK; -} - -#endif /* Convert sample data from U8 to S16 */ @@ -252,8 +219,7 @@ } /* Converts the given module in preparation for playing it. - * This involves sample format conversion (8 to 16 bit, or - * if floating point mixing is enabled, 8/16 bit to FP.) + * This involves sample format conversion (8 to 16 bit, etc.) * * NOTICE! The converted module can only be saved in JSSMOD * format, but this is not recommended. @@ -272,16 +238,7 @@ { int res; void *data = NULL; -#ifdef JSS_MIX_FP - if (inst->flags & jsfFP) - continue; - if ((res = jssConvertSampleToFP(&data, inst->data, inst->size, inst->flags)) != DMERR_OK) - return res; - - inst->flags &= !(jsf16bit); - inst->flags |= jsfFP; -#else if (inst->flags & jsf16bit) continue; @@ -289,7 +246,6 @@ return res; inst->flags |= jsf16bit; -#endif dmFree(inst->data); inst->data = data; } diff -r e0e470c3fc8e -r 8725853609db jssmod.h --- a/jssmod.h Mon Oct 01 06:28:29 2012 +0300 +++ b/jssmod.h Mon Oct 01 06:59:00 2012 +0300 @@ -290,9 +290,6 @@ #endif BOOL jssDecodeSample8(Uint8 *, const size_t, const int); BOOL jssDecodeSample16(Uint16 *, const size_t, const int); -#ifdef JSS_MIX_FP -int jssConvertSampleToFP(void **dst, void * src, const size_t len, const int flags); -#endif int jssConvertModuleForPlaying(JSSModule *module); JSSModule * jssAllocateModule(void); int jssFreeModule(JSSModule *);