aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-11-25 02:08:48 -0800
committerChris Robinson <[email protected]>2014-11-25 02:08:48 -0800
commitefb5c5eecd3b2fd1744f8ce965653fed3a76cf01 (patch)
tree46fb3f1e0f0ae94f6241a954c47a1d03d3c107e0 /Alc/ALu.c
parent42ef85d3f6803cc413d5867bb278bee2a8996e06 (diff)
Use linear gain stepping
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index d964aa79..78578a87 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -178,7 +178,7 @@ static void UpdateDryStepping(DirectParams *params, ALuint num_chans, ALuint ste
ALfloat delta;
ALuint i, j;
- if(steps == 0)
+ if(steps < 2)
{
for(i = 0;i < num_chans;i++)
{
@@ -186,7 +186,7 @@ static void UpdateDryStepping(DirectParams *params, ALuint num_chans, ALuint ste
for(j = 0;j < params->OutChannels;j++)
{
gains[j].Current = gains[j].Target;
- gains[j].Step = 1.0f;
+ gains[j].Step = 0.0f;
}
}
params->Counter = 0;
@@ -199,13 +199,11 @@ static void UpdateDryStepping(DirectParams *params, ALuint num_chans, ALuint ste
MixGains *gains = params->Gains[i];
for(j = 0;j < params->OutChannels;j++)
{
- ALfloat cur = maxf(gains[j].Current, FLT_EPSILON);
- ALfloat trg = maxf(gains[j].Target, FLT_EPSILON);
- if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
- gains[j].Step = powf(trg/cur, delta);
+ ALfloat diff = gains[j].Target - gains[j].Current;
+ if(fabs(diff) >= GAIN_SILENCE_THRESHOLD)
+ gains[j].Step = diff * delta;
else
- gains[j].Step = 1.0f;
- gains[j].Current = cur;
+ gains[j].Step = 0.0f;
}
}
params->Counter = steps;
@@ -215,10 +213,10 @@ static void UpdateWetStepping(SendParams *params, ALuint steps)
{
ALfloat delta;
- if(steps == 0)
+ if(steps < 2)
{
params->Gain.Current = params->Gain.Target;
- params->Gain.Step = 1.0f;
+ params->Gain.Step = 0.0f;
params->Counter = 0;
return;
@@ -226,14 +224,11 @@ static void UpdateWetStepping(SendParams *params, ALuint steps)
delta = 1.0f / (ALfloat)steps;
{
- ALfloat cur, trg;
- cur = maxf(params->Gain.Current, FLT_EPSILON);
- trg = maxf(params->Gain.Target, FLT_EPSILON);
- if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
- params->Gain.Step = powf(trg/cur, delta);
+ ALfloat diff = params->Gain.Target - params->Gain.Current;
+ if(fabs(diff) >= GAIN_SILENCE_THRESHOLD)
+ params->Gain.Step = diff * delta;
else
- params->Gain.Step = 1.0f;
- params->Gain.Current = cur;
+ params->Gain.Step = 0.0f;
}
params->Counter = steps;
}
@@ -524,9 +519,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i].Target = Target[i];
}
- /* B-Format cannot handle logarithmic gain stepping, since the gain can
- * switch between positive and negative values. */
- UpdateDryStepping(&voice->Direct, num_channels, 0);
+ UpdateDryStepping(&voice->Direct, num_channels, (voice->Direct.Moving ? 64 : 0));
+ voice->Direct.Moving = AL_TRUE;
voice->IsHrtf = AL_FALSE;
for(i = 0;i < NumSends;i++)