aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer_c.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-10-05 20:33:45 -0700
committerChris Robinson <[email protected]>2016-10-05 20:33:45 -0700
commit9b8f36b75879d2fee652c9ff81e1cb5db665a5c5 (patch)
treedae9a1458b8f2d12fab0962792a8bf3528e111ab /Alc/mixer_c.c
parent1e1a8837f8a595639aa8933889b892766379d111 (diff)
Pass current and target gains directly for mixing
Diffstat (limited to 'Alc/mixer_c.c')
-rw-r--r--Alc/mixer_c.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index 3e726df5..a75ad002 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -172,17 +172,20 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize)
{
- ALfloat gain, step;
+ ALfloat gain, delta, step;
ALuint c;
+ delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f;
+
for(c = 0;c < OutChans;c++)
{
ALuint pos = 0;
- gain = Gains[c].Current;
- step = Gains[c].Step;
- if(step != 0.0f && Counter > 0)
+ gain = CurrentGains[c];
+ step = (TargetGains[c] - gain) * delta;
+ if(fabsf(step) > FLT_EPSILON)
{
ALuint minsize = minu(BufferSize, Counter);
for(;pos < minsize;pos++)
@@ -191,8 +194,8 @@ void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[B
gain += step;
}
if(pos == Counter)
- gain = Gains[c].Target;
- Gains[c].Current = gain;
+ gain = TargetGains[c];
+ CurrentGains[c] = gain;
}
if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))