aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alAuxEffectSlot.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-02-18 21:58:58 -0800
committerChris Robinson <[email protected]>2008-02-18 21:58:58 -0800
commit847b3e8b618466780459d0875a0f6a0c77dee953 (patch)
treecc9424d6a907254d029b038ba86e2dd448b5be99 /OpenAL32/alAuxEffectSlot.c
parentb1bdd7c89f285649e5a3af2dbe68b358accf47eb (diff)
Preserve data and position when reallocating the reverb effect
Still not perfect, but better for when the size doesn't change
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.c')
-rw-r--r--OpenAL32/alAuxEffectSlot.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index f80c31a0..7f073435 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -493,16 +493,20 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot,
alSetError(AL_OUT_OF_MEMORY);
return;
}
+ if(ALEffectSlot->ReverbBuffer)
+ memcpy(ptr, ALEffectSlot->ReverbBuffer, min(size, ALEffectSlot->ReverbLength)*sizeof(ALfloat));
ALEffectSlot->ReverbLength = size;
- ALEffectSlot->ReverbPos = 0;
+ ALEffectSlot->ReverbPos %= size;
ALEffectSlot->ReverbReflectPos = (ALuint)(ALEffectSlot->ReverbLength -
((ALfloat)Context->Frequency *
- effect->Reverb.ReflectionsDelay)) %
+ effect->Reverb.ReflectionsDelay) +
+ ALEffectSlot->ReverbPos) %
ALEffectSlot->ReverbLength;
ALEffectSlot->ReverbLatePos = (ALuint)(ALEffectSlot->ReverbLength -
((ALfloat)Context->Frequency *
(effect->Reverb.LateReverbDelay +
- effect->Reverb.ReflectionsDelay))) %
+ effect->Reverb.ReflectionsDelay)) +
+ ALEffectSlot->ReverbPos) %
ALEffectSlot->ReverbLength;
ALEffectSlot->ReverbDecayGain = pow(1.0/32768.0, 1.0/(effect->Reverb.DecayTime/reverbwait));
}