diff options
author | Chris Robinson <[email protected]> | 2009-12-07 10:35:30 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-12-07 10:35:30 -0800 |
commit | 4697e946d3ac61c05512d685a97e4632a392c162 (patch) | |
tree | 9ec86073c68d193730c1bdeb48d0f9234c739aca /Alc | |
parent | 9286e3984c3276dd720629a1ee4615d6f9acca73 (diff) |
Internally store 32-bit float buffer data, and mix accordingly
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -61,18 +61,23 @@ ALboolean DuplicateStereo = AL_FALSE; static __inline ALfloat aluF2F(ALfloat Value) { - if(Value < 0.f) return Value/32768.f; - if(Value > 0.f) return Value/32767.f; - return 0.f; + return Value; } static __inline ALshort aluF2S(ALfloat Value) { ALint i; - i = (ALint)Value; - i = __min( 32767, i); - i = __max(-32768, i); + if(Value < 0.0f) + { + i = (ALint)(Value*32768.0f); + i = max(-32768, i); + } + else + { + i = (ALint)(Value*32767.0f); + i = min( 32767, i); + } return ((ALshort)i); } @@ -852,9 +857,9 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource, } } -static __inline ALshort lerp(ALshort val1, ALshort val2, ALint frac) +static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALint frac) { - return val1 + (((val2-val1)*frac)>>FRACTIONBITS); + return val1 + ((val2-val1)*(frac * (1.0f/(1<<FRACTIONBITS)))); } static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANNELS], ALuint SamplesToDo) @@ -984,7 +989,7 @@ another_source: { ALuint DataSize = 0; ALbuffer *ALBuffer; - ALshort *Data; + ALfloat *Data; ALuint BufferSize; /* Get buffer info */ |