aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-04 00:13:19 -0700
committerChris Robinson <[email protected]>2014-05-04 00:13:19 -0700
commita2bb4c3f1344ad5876181fd0c3131e018915276e (patch)
treeab376924a6b9fb23a453d910c69a8168ae6475b8
parentd066c7b124a7efa771996bc7ba09e0e074683739 (diff)
Always use the current gains when mixing
The current gain gets explicitly set to the target when the stepping is finished to ensure the target is still used. This way, however, will allow for asynchronously 'canceling' a fade by setting the counter to 0.
-rw-r--r--Alc/mixer_c.c10
-rw-r--r--Alc/mixer_neon.c14
-rw-r--r--Alc/mixer_sse.c15
3 files changed, 22 insertions, 17 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index efbbf9cb..2b8325ae 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -93,19 +93,20 @@ void MixDirect_C(DirectParams *params, const ALfloat *restrict data, ALuint srcc
for(c = 0;c < MaxChannels;c++)
{
ALuint pos = 0;
+ DrySend = params->Mix.Gains.Current[srcchan][c];
Step = params->Mix.Gains.Step[srcchan][c];
if(Step != 1.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;
}
+ if(pos == Counter)
+ DrySend = params->Mix.Gains.Target[srcchan][c];
params->Mix.Gains.Current[srcchan][c] = DrySend;
}
- DrySend = params->Mix.Gains.Target[srcchan][c];
if(!(DrySend > GAIN_SILENCE_THRESHOLD))
continue;
for(;pos < BufferSize;pos++)
@@ -123,19 +124,20 @@ void MixSend_C(SendParams *params, const ALfloat *restrict data,
{
ALuint pos = 0;
+ WetSend = params->Gain.Current;
Step = params->Gain.Step;
if(Step != 1.0f && Counter > 0)
{
- WetSend = params->Gain.Current;
for(;pos < BufferSize && pos < Counter;pos++)
{
OutBuffer[0][OutPos+pos] += data[pos]*WetSend;
WetSend *= Step;
}
+ if(pos == Counter)
+ WetSend = params->Gain.Target;
params->Gain.Current = WetSend;
}
- WetSend = params->Gain.Target;
if(!(WetSend > GAIN_SILENCE_THRESHOLD))
return;
for(;pos < BufferSize;pos++)
diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c
index 1b695d81..0fa80939 100644
--- a/Alc/mixer_neon.c
+++ b/Alc/mixer_neon.c
@@ -89,22 +89,23 @@ void MixDirect_Neon(DirectParams *params, const ALfloat *restrict data, ALuint s
for(c = 0;c < MaxChannels;c++)
{
ALuint pos = 0;
+ DrySend = params->Mix.Gains.Current[srcchan][c];
Step = params->Mix.Gains.Step[srcchan][c];
if(Step != 1.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;
}
+ if(pos == Counter)
+ DrySend = params->Mix.Gains.Target[srcchan][c];
+ params->Mix.Gains.Current[srcchan][c] = DrySend;
/* Mix until pos is aligned with 4 or the mix is done. */
for(;pos < BufferSize && (pos&3) != 0;pos++)
OutBuffer[c][OutPos+pos] += data[pos]*DrySend;
- params->Mix.Gains.Current[srcchan][c] = DrySend;
}
- DrySend = params->Mix.Gains.Target[srcchan][c];
if(!(DrySend > GAIN_SILENCE_THRESHOLD))
continue;
gain = vdupq_n_f32(DrySend);
@@ -131,21 +132,22 @@ void MixSend_Neon(SendParams *params, const ALfloat *restrict data,
{
ALuint pos = 0;
+ WetGain = params->Gain.Current;
Step = params->Gain.Step;
if(Step != 1.0f && Counter > 0)
{
- WetGain = params->Gain.Current;
for(;pos < BufferSize && pos < Counter;pos++)
{
OutBuffer[0][OutPos+pos] += data[pos]*WetGain;
WetGain *= Step;
}
+ if(pos == Counter)
+ WetGain = params->Gain.Target;
+ params->Gain.Current = WetGain;
for(;pos < BufferSize && (pos&3) != 0;pos++)
OutBuffer[0][OutPos+pos] += data[pos]*WetGain;
- params->Gain.Current = WetGain;
}
- WetGain = params->Gain.Target;
if(!(WetGain > GAIN_SILENCE_THRESHOLD))
return;
gain = vdupq_n_f32(WetGain);
diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c
index a2b8461d..645053d9 100644
--- a/Alc/mixer_sse.c
+++ b/Alc/mixer_sse.c
@@ -152,10 +152,10 @@ void MixDirect_SSE(DirectParams *params, const ALfloat *restrict data, ALuint sr
for(c = 0;c < MaxChannels;c++)
{
ALuint pos = 0;
+ DrySend = params->Mix.Gains.Current[srcchan][c];
Step = params->Mix.Gains.Step[srcchan][c];
if(Step != 1.0f && Counter > 0)
{
- DrySend = params->Mix.Gains.Current[srcchan][c];
/* Mix with applying gain steps in aligned multiples of 4. */
if(BufferSize-pos > 3 && Counter-pos > 3)
{
@@ -182,13 +182,14 @@ void MixDirect_SSE(DirectParams *params, const ALfloat *restrict data, ALuint sr
OutBuffer[c][OutPos+pos] += data[pos]*DrySend;
DrySend *= Step;
}
+ if(pos == Counter)
+ DrySend = params->Mix.Gains.Target[srcchan][c];
+ params->Mix.Gains.Current[srcchan][c] = DrySend;
/* Mix until pos is aligned with 4 or the mix is done. */
for(;pos < BufferSize && (pos&3) != 0;pos++)
OutBuffer[c][OutPos+pos] += data[pos]*DrySend;
- params->Mix.Gains.Current[srcchan][c] = DrySend;
}
- DrySend = params->Mix.Gains.Target[srcchan][c];
if(!(DrySend > GAIN_SILENCE_THRESHOLD))
continue;
gain = _mm_set1_ps(DrySend);
@@ -215,11 +216,10 @@ void MixSend_SSE(SendParams *params, const ALfloat *restrict data,
{
ALuint pos = 0;
-
+ WetGain = params->Gain.Current;
Step = params->Gain.Step;
if(Step != 1.0f && Counter > 0)
{
- WetGain = params->Gain.Current;
if(BufferSize-pos > 3 && Counter-pos > 3)
{
gain = _mm_set_ps(
@@ -244,12 +244,13 @@ void MixSend_SSE(SendParams *params, const ALfloat *restrict data,
OutBuffer[0][OutPos+pos] += data[pos]*WetGain;
WetGain *= Step;
}
+ if(pos == Counter)
+ WetGain = params->Gain.Target;
+ params->Gain.Current = WetGain;
for(;pos < BufferSize && (pos&3) != 0;pos++)
OutBuffer[0][OutPos+pos] += data[pos]*WetGain;
- params->Gain.Current = WetGain;
}
- WetGain = params->Gain.Target;
if(!(WetGain > GAIN_SILENCE_THRESHOLD))
return;
gain = _mm_set1_ps(WetGain);