diff options
author | Chris Robinson <[email protected]> | 2014-03-23 06:57:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-23 06:57:00 -0700 |
commit | 81e049bd47cc2423dc6983c47d9f99e70c3135ac (patch) | |
tree | 74424462f69b97dffaebdc04dc263bf5eeb6183c /Alc/mixer_c.c | |
parent | 0ce0a88fd67ddcf7cb5248ac08d36cfa1c0013eb (diff) |
Step mixing gains per-sample for non-HRTF mixing
This fades the dry mixing gains using a logarithmic curve, which should produce
a smoother transition than a linear one. It functions similarly to a linear
fade except that
step = (target - current) / numsteps;
...
gain += step;
becomes
step = powf(target / current, 1.0f / numsteps);
...
gain *= step;
where 'target' and 'current' are clamped to a lower bound that is greater than
0 (which makes no sense on a logarithmic scale).
Consequently, the non-HRTF direct mixers do not do not feed into the click
removal and pending click buffers, as this per-sample fading would do an
adequate job of stopping clicks and pops caused by extreme gain changes. These
buffers should be removed shortly.
Diffstat (limited to 'Alc/mixer_c.c')
-rw-r--r-- | Alc/mixer_c.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index 6b21e67a..e83655e6 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -83,27 +83,33 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], void MixDirect_C(DirectParams *params, const ALfloat *restrict data, ALuint srcchan, - ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) + ALuint OutPos, ALuint UNUSED(SamplesToDo), ALuint BufferSize) { ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer; - ALfloat *restrict ClickRemoval = params->ClickRemoval; - ALfloat *restrict PendingClicks = params->PendingClicks; - ALfloat DrySend; - ALuint pos; + ALuint Counter = maxu(params->Counter, OutPos) - OutPos; + ALfloat DrySend, Step; ALuint c; for(c = 0;c < MaxChannels;c++) { - DrySend = params->Mix.Gains[srcchan][c]; + ALuint pos = 0; + Step = params->Mix.Gains.Step[srcchan][c]; + if(Step != 0.0f && Counter > 0) + { + DrySend = params->Mix.Gains.Current[srcchan][c]; + for(;pos < BufferSize && pos < Counter;pos++) + { + OutBuffer[c][OutPos+pos] += data[pos]*DrySend; + DrySend *= Step; + } + params->Mix.Gains.Current[srcchan][c] = DrySend; + } + + DrySend = params->Mix.Gains.Target[srcchan][c]; if(!(DrySend > GAIN_SILENCE_THRESHOLD)) continue; - - if(OutPos == 0) - ClickRemoval[c] -= data[0]*DrySend; - for(pos = 0;pos < BufferSize;pos++) + for(;pos < BufferSize;pos++) OutBuffer[c][OutPos+pos] += data[pos]*DrySend; - if(OutPos+pos == SamplesToDo) - PendingClicks[c] += data[pos]*DrySend; } } |