diff options
author | Chris Robinson <[email protected]> | 2011-10-01 02:38:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-10-01 02:38:28 -0700 |
commit | a486045f7cade874d422a03277be4db8c14e8f24 (patch) | |
tree | 075c3000832de467df3251c7c92deb54a29d0eeb /Alc/alcReverb.c | |
parent | 0e7dc93681278e73aa76ce3bf0cb0ff1e340455a (diff) |
Improve index calculation for reverb modulation updates
Diffstat (limited to 'Alc/alcReverb.c')
-rw-r--r-- | Alc/alcReverb.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 1323c497..589be6e3 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -876,7 +876,7 @@ static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloa // downswing will sound stronger than the upswing. static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequency, ALverbState *State) { - ALfloat length; + ALuint range; /* Modulation is calculated in two parts. * @@ -886,15 +886,10 @@ static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequenc * minimum (1 sample) and when the timing changes, the index is rescaled * to the new range (to keep the sinus consistent). */ - length = modTime * frequency; - if (length >= 1.0f) { - State->Mod.Index = fastf2u(State->Mod.Index * length / - State->Mod.Range); - State->Mod.Range = fastf2u(length); - } else { - State->Mod.Index = 0; - State->Mod.Range = 1; - } + range = maxu(fastf2u(modTime*frequency), 1); + State->Mod.Index = (ALuint)(State->Mod.Index * (ALuint64)range / + State->Mod.Range); + State->Mod.Range = range; /* The modulation depth effects the amount of frequency change over the * range of the sinus. It needs to be scaled by the modulation time so |