aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-09-23 08:43:39 -0700
committerChris Robinson <[email protected]>2010-09-23 08:43:39 -0700
commit8d67cdfaab1701738659a64874f4bef1b3034c8e (patch)
treecead5cda468f585447e134e7db557411aae5ae6e /Alc/mixer.c
parent67ba924ed3d03e4618e01e37f6997d960de51b27 (diff)
Convert float to short similar to short to float
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r--Alc/mixer.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 09bf916c..781fec82 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -44,12 +44,11 @@ static __inline ALfloat aluF2F(ALfloat Value)
static __inline ALshort aluF2S(ALfloat Value)
{
- ALint i = 0;
+ ALint i;
- if(Value < -1.0f) i = -32768;
- else if(Value < 0.0f) i = (ALint)(Value*32768.0f);
- else if(Value > 1.0f) i = 32767;
- else if(Value > 0.0f) i = (ALint)(Value*32767.0f);
+ if(Value <= -1.0f) i = -32768;
+ else if(Value >= 1.0f) i = 32767;
+ else i = (ALint)(Value*32767.5f - 0.5f);
return ((ALshort)i);
}