aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/sample_cvt.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-03-31 06:54:46 -0700
committerChris Robinson <[email protected]>2017-03-31 06:54:46 -0700
commitac8b4aa5f66db68609459a9444c2a7083b2e8f28 (patch)
treed4f05d86836bcfba85fdb8accee4a95034fbad2d /OpenAL32/sample_cvt.c
parent9fb07101dc0ab5b7f2785584b4c29e18232ba99c (diff)
Convert integer samples to float using a power-of-2 divisor
This should cut down on unnecessary quantization noise (however minor) for 8- and 16-bit samples. Unfortunately a power-of-2 multiple can't be used as easily for converting float samples to integer, due to integer types having a non- power-of-2 maximum amplitude (it'd require more per-sample clamping).
Diffstat (limited to 'OpenAL32/sample_cvt.c')
-rw-r--r--OpenAL32/sample_cvt.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c
index aff3de83..daea548a 100644
--- a/OpenAL32/sample_cvt.c
+++ b/OpenAL32/sample_cvt.c
@@ -608,17 +608,17 @@ static inline T Conv_##T##_##UT(UT val) { return (T)Conv_##ST##_##UT(val) * OP;
#define DECL_TEMPLATE2(T1, T2, OP) \
DECL_TEMPLATE(T1, AL##T2, ALu##T2, OP)
-DECL_TEMPLATE2(ALfloat, byte, (1.0f/127.0f))
-DECL_TEMPLATE2(ALdouble, byte, (1.0/127.0))
-DECL_TEMPLATE2(ALfloat, short, (1.0f/32767.0f))
-DECL_TEMPLATE2(ALdouble, short, (1.0/32767.0))
-DECL_TEMPLATE2(ALdouble, int, (1.0/2147483647.0))
+DECL_TEMPLATE2(ALfloat, byte, (1.0f/128.0f))
+DECL_TEMPLATE2(ALdouble, byte, (1.0/128.0))
+DECL_TEMPLATE2(ALfloat, short, (1.0f/32768.0f))
+DECL_TEMPLATE2(ALdouble, short, (1.0/32768.0))
+DECL_TEMPLATE2(ALdouble, int, (1.0/2147483648.0))
/* Special handling for int32 to float32, since it would overflow. */
static inline ALfloat Conv_ALfloat_ALint(ALint val)
-{ return (ALfloat)(val>>7) * (1.0f/16777215.0f); }
+{ return (ALfloat)(val>>7) * (1.0f/16777216.0f); }
static inline ALfloat Conv_ALfloat_ALuint(ALuint val)
-{ return (ALfloat)(Conv_ALint_ALuint(val)>>7) * (1.0f/16777215.0f); }
+{ return (ALfloat)(Conv_ALint_ALuint(val)>>7) * (1.0f/16777216.0f); }
#undef DECL_TEMPLATE2
#undef DECL_TEMPLATE