diff options
author | Chris Robinson <[email protected]> | 2010-09-23 08:43:39 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-09-23 08:43:39 -0700 |
commit | 8d67cdfaab1701738659a64874f4bef1b3034c8e (patch) | |
tree | cead5cda468f585447e134e7db557411aae5ae6e /Alc | |
parent | 67ba924ed3d03e4618e01e37f6997d960de51b27 (diff) |
Convert float to short similar to short to float
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/mixer.c | 9 |
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); } |