diff options
author | Chris Robinson <[email protected]> | 2010-01-11 06:19:54 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-01-11 06:19:54 -0800 |
commit | 93b584ff8419f76d934e0a6e9cbc55cf907ea259 (patch) | |
tree | 908aefd3b355d119ba9c6ded7db7295397ee58a4 | |
parent | 705849ca7371176d4e645b92898cb9a235602f9f (diff) |
Add a cosine resampler
-rw-r--r-- | Alc/ALu.c | 17 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 1 | ||||
-rw-r--r-- | alsoftrc.sample | 1 |
3 files changed, 19 insertions, 0 deletions
@@ -870,6 +870,11 @@ static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALint frac) { return val1 + ((val2-val1)*(frac * (1.0f/(1<<FRACTIONBITS)))); } +static __inline ALfloat cos_lerp(ALfloat val1, ALfloat val2, ALint frac) +{ + ALfloat mult = (1.0f-cos(frac * (1.0f/(1<<FRACTIONBITS)) * M_PI)) * 0.5f; + return val1 + ((val2-val1)*mult); +} static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANNELS], ALuint SamplesToDo) { @@ -1106,6 +1111,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } @@ -1153,6 +1160,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } @@ -1171,6 +1180,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } @@ -1190,6 +1201,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } @@ -1210,6 +1223,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } @@ -1230,6 +1245,8 @@ another_source: break; case LINEAR: DO_MIX(lerp); break; + case COSINE: DO_MIX(cos_lerp); + break; case RESAMPLER_MAX: break; } diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index de746c61..2e1cf3de 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -25,6 +25,7 @@ extern "C" { typedef enum { POINT = 0, LINEAR, + COSINE, RESAMPLER_MAX } resampler_t; diff --git a/alsoftrc.sample b/alsoftrc.sample index bda8dd45..aa95121e 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -64,6 +64,7 @@ # Selects the resampler used when mixing sources. Valid values are: # 0 - None (nearest sample, no interpolation) # 1 - Linear (extrapolates samples using a linear slope between samples) +# 2 - Cosine (extrapolates using a (co)sine slope) # Specifying other values will result in using the default (linear). #resampler = 1 |