aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer/mixer_c.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-05-14 23:41:29 -0700
committerChris Robinson <[email protected]>2018-05-14 23:41:29 -0700
commit4ee04cd444e770fb12adf607c9711f7d892f76bd (patch)
tree6892db1546a2da8617e6ed7948c65f0ecbc6dca0 /Alc/mixer/mixer_c.c
parent43dccc880703d6e07e86a32e38c5c4cac235016f (diff)
Use a step counter for gain stepping
This should provide more stable stepping, preventing floating-point errors from accumulating on each step/sample.
Diffstat (limited to 'Alc/mixer/mixer_c.c')
-rw-r--r--Alc/mixer/mixer_c.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Alc/mixer/mixer_c.c b/Alc/mixer/mixer_c.c
index 84485206..25149e00 100644
--- a/Alc/mixer/mixer_c.c
+++ b/Alc/mixer/mixer_c.c
@@ -134,13 +134,16 @@ void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[
if(fabsf(step) > FLT_EPSILON)
{
ALsizei minsize = mini(BufferSize, Counter);
+ ALfloat step_count = 0.0f;
for(;pos < minsize;pos++)
{
- OutBuffer[c][OutPos+pos] += data[pos]*gain;
- gain += step;
+ OutBuffer[c][OutPos+pos] += data[pos] * (gain + step*step_count);
+ step_count += 1.0f;
}
if(pos == Counter)
gain = TargetGains[c];
+ else
+ gain += step*step_count;
CurrentGains[c] = gain;
}