aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c34
-rw-r--r--Alc/mixer_c.c4
-rw-r--r--Alc/mixer_neon.c4
-rw-r--r--Alc/mixer_sse.c14
4 files changed, 25 insertions, 31 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++)
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index fa87c3d4..f5898024 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -118,12 +118,12 @@ void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[B
ALuint pos = 0;
gain = Gains[c].Current;
step = Gains[c].Step;
- if(step != 1.0f && Counter > 0)
+ if(step != 0.0f && Counter > 0)
{
for(;pos < BufferSize && pos < Counter;pos++)
{
OutBuffer[c][OutPos+pos] += data[pos]*gain;
- gain *= step;
+ gain += step;
}
if(pos == Counter)
gain = Gains[c].Target;
diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c
index a068d02b..8f79186d 100644
--- a/Alc/mixer_neon.c
+++ b/Alc/mixer_neon.c
@@ -106,12 +106,12 @@ void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer
ALuint pos = 0;
gain = Gains[c].Current;
step = Gains[c].Step;
- if(step != 1.0f && Counter > 0)
+ if(step != 0.0f && Counter > 0)
{
for(;pos < BufferSize && pos < Counter;pos++)
{
OutBuffer[c][OutPos+pos] += data[pos]*gain;
- gain *= step;
+ gain += step;
}
if(pos == Counter)
gain = Gains[c].Target;
diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c
index 75f50f88..4dfc748d 100644
--- a/Alc/mixer_sse.c
+++ b/Alc/mixer_sse.c
@@ -167,23 +167,23 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)
ALuint pos = 0;
gain = Gains[c].Current;
step = Gains[c].Step;
- if(step != 1.0f && Counter > 0)
+ if(step != 0.0f && Counter > 0)
{
/* Mix with applying gain steps in aligned multiples of 4. */
if(BufferSize-pos > 3 && Counter-pos > 3)
{
gain4 = _mm_setr_ps(
gain,
- gain * step,
- gain * step * step,
- gain * step * step * step
+ gain + step,
+ gain + step + step,
+ gain + step + step + step
);
- step4 = _mm_set1_ps(step * step * step * step);
+ step4 = _mm_set1_ps(step + step + step + step);
do {
const __m128 val4 = _mm_load_ps(&data[pos]);
__m128 dry4 = _mm_load_ps(&OutBuffer[c][OutPos+pos]);
dry4 = _mm_add_ps(dry4, _mm_mul_ps(val4, gain4));
- gain4 = _mm_mul_ps(gain4, step4);
+ gain4 = _mm_add_ps(gain4, step4);
_mm_store_ps(&OutBuffer[c][OutPos+pos], dry4);
pos += 4;
} while(BufferSize-pos > 3 && Counter-pos > 3);
@@ -193,7 +193,7 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)
for(;pos < BufferSize && pos < Counter;pos++)
{
OutBuffer[c][OutPos+pos] += data[pos]*gain;
- gain *= step;
+ gain += step;
}
if(pos == Counter)
gain = Gains[c].Target;