aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-23 16:11:21 -0700
committerChris Robinson <[email protected]>2014-03-23 16:11:21 -0700
commit52deb557d5466e7dd0b78dceb16f2ad5296bbcd4 (patch)
tree14bf48e2d74ce459fe37bb5feb0b556aa09d174e /Alc/ALu.c
parent83038c0dab0727b76765a8feed5a2c3c23c9915b (diff)
Add gain stepping to the send mixers
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 10e2a45d..d00620eb 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -565,7 +565,27 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->DryMix = SelectDirectMixer();
}
for(i = 0;i < NumSends;i++)
- src->Send[i].Gain = WetGain[i];
+ {
+ if(src->Send[i].Moving)
+ {
+ ALfloat cur = maxf(src->Send[i].Gain.Current, GAIN_SILENCE_THRESHOLD);
+ ALfloat trg = maxf(src->Send[i].Gain.Target, GAIN_SILENCE_THRESHOLD);
+ if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
+ src->Send[i].Gain.Step = powf(trg/cur, 1.0f/64.0f);
+ else
+ src->Send[i].Gain.Step = 1.0f;
+ src->Send[i].Gain.Current = cur;
+ src->Send[i].Counter = 64;
+ }
+ else
+ {
+ src->Send[i].Gain.Current = WetGain[i];
+ src->Send[i].Gain.Target = WetGain[i];
+ src->Send[i].Gain.Step = 1.0f;
+ src->Send[i].Counter = 0;
+ src->Send[i].Moving = AL_TRUE;
+ }
+ }
src->WetMix = SelectSendMixer();
{
@@ -1050,7 +1070,27 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->DryMix = SelectDirectMixer();
}
for(i = 0;i < NumSends;i++)
- src->Send[i].Gain = WetGain[i];
+ {
+ if(src->Send[i].Moving)
+ {
+ ALfloat cur = maxf(src->Send[i].Gain.Current, GAIN_SILENCE_THRESHOLD);
+ ALfloat trg = maxf(src->Send[i].Gain.Target, GAIN_SILENCE_THRESHOLD);
+ if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
+ src->Send[i].Gain.Step = powf(trg/cur, 1.0f/64.0f);
+ else
+ src->Send[i].Gain.Step = 1.0f;
+ src->Send[i].Gain.Current = cur;
+ src->Send[i].Counter = 64;
+ }
+ else
+ {
+ src->Send[i].Gain.Current = WetGain[i];
+ src->Send[i].Gain.Target = WetGain[i];
+ src->Send[i].Gain.Step = 1.0f;
+ src->Send[i].Counter = 0;
+ src->Send[i].Moving = AL_TRUE;
+ }
+ }
src->WetMix = SelectSendMixer();
{