aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/effects/reverb.c57
-rw-r--r--Alc/mixer.c102
-rw-r--r--Alc/mixer_c.c17
-rw-r--r--Alc/mixer_defs.h9
-rw-r--r--Alc/mixer_neon.c17
-rw-r--r--Alc/mixer_sse.c17
6 files changed, 64 insertions, 155 deletions
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 17d2fa84..46883104 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1384,33 +1384,6 @@ static ALvoid EAXVerbPass(ALreverbState *State, ALuint todo, ALfloat (*restrict
State->Offset += todo;
}
-static void DoMix(const ALfloat *restrict src, ALfloat (*dst)[BUFFERSIZE], ALuint num_chans,
- const ALfloat *restrict target_gains, ALfloat *restrict current_gains,
- ALfloat delta, ALuint offset, ALuint total_rem, ALuint todo)
-{
- MixGains gains[MAX_OUTPUT_CHANNELS];
- ALuint c;
-
- for(c = 0;c < num_chans;c++)
- {
- ALfloat diff;
- gains[c].Target = target_gains[c];
- gains[c].Current = current_gains[c];
- diff = gains[c].Target - gains[c].Current;
- if(fabsf(diff) >= GAIN_SILENCE_THRESHOLD)
- gains[c].Step = diff * delta;
- else
- {
- gains[c].Current = gains[c].Target;
- gains[c].Step = 0.0f;
- }
- }
-
- MixSamples(src, num_chans, dst, gains, total_rem, offset, todo);
-
- for(c = 0;c < num_chans;c++)
- current_gains[c] = gains[c].Current;
-}
static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
@@ -1428,7 +1401,6 @@ static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint Samples
/* Process reverb for these samples. */
for(base = 0;base < SamplesToDo;)
{
- const ALfloat delta = 1.0f / (ALfloat)(SamplesToDo-base);
ALuint todo = minu(SamplesToDo-base, MAX_UPDATE_SAMPLES);
/* Convert B-Foramt to A-Format for processing. */
@@ -1444,17 +1416,15 @@ static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint Samples
* B-Format.
*/
for(c = 0;c < 4;c++)
- {
- DoMix(early[c], SamplesOut, NumChannels, State->Early.PanGain[c],
- State->Early.CurrentGain[c], delta, base, SamplesToDo-base, todo
+ MixSamples(early[c], NumChannels, SamplesOut,
+ State->Early.CurrentGain[c], State->Early.PanGain[c],
+ SamplesToDo-base, base, todo
);
- }
for(c = 0;c < 4;c++)
- {
- DoMix(late[c], SamplesOut, NumChannels, State->Late.PanGain[c],
- State->Late.CurrentGain[c], delta, base, SamplesToDo, todo
+ MixSamples(late[c], NumChannels, SamplesOut,
+ State->Late.CurrentGain[c], State->Late.PanGain[c],
+ SamplesToDo-base, base, todo
);
- }
base += todo;
}
@@ -1476,7 +1446,6 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo,
/* Process reverb for these samples. */
for(base = 0;base < SamplesToDo;)
{
- const ALfloat delta = 1.0f / (ALfloat)(SamplesToDo-base);
ALuint todo = minu(SamplesToDo-base, MAX_UPDATE_SAMPLES);
memset(afmt, 0, 4*MAX_UPDATE_SAMPLES*sizeof(float));
@@ -1488,17 +1457,15 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo,
EAXVerbPass(State, todo, afmt, early, late);
for(c = 0;c < 4;c++)
- {
- DoMix(early[c], SamplesOut, NumChannels, State->Early.PanGain[c],
- State->Early.CurrentGain[c], delta, base, SamplesToDo-base, todo
+ MixSamples(early[c], NumChannels, SamplesOut,
+ State->Early.CurrentGain[c], State->Early.PanGain[c],
+ SamplesToDo-base, base, todo
);
- }
for(c = 0;c < 4;c++)
- {
- DoMix(late[c], SamplesOut, NumChannels, State->Late.PanGain[c],
- State->Late.CurrentGain[c], delta, base, SamplesToDo, todo
+ MixSamples(late[c], NumChannels, SamplesOut,
+ State->Late.CurrentGain[c], State->Late.PanGain[c],
+ SamplesToDo-base, base, todo
);
- }
base += todo;
}
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 864e2395..a0132e0f 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -393,6 +393,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
ALuint NumChannels;
ALuint SampleSize;
ALint64 DataSize64;
+ ALuint Counter;
ALuint IrSize;
ALuint chan, send, j;
@@ -411,22 +412,10 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ?
Resample_copy32_C : ResampleSamples);
+ Counter = voice->Moving ? SamplesToDo : 0;
OutPos = 0;
do {
ALuint SrcBufferSize, DstBufferSize;
- ALuint Counter;
- ALfloat Delta;
-
- if(!voice->Moving)
- {
- Counter = 0;
- Delta = 0.0f;
- }
- else
- {
- Counter = SamplesToDo - OutPos;
- Delta = 1.0f / (ALfloat)Counter;
- }
/* Figure out how many buffer samples will be needed */
DataSize64 = SamplesToDo-OutPos;
@@ -575,42 +564,12 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
);
if(!voice->IsHrtf)
{
- ALfloat *restrict currents = parms->Gains.Current;
- const ALfloat *targets = parms->Gains.Target;
- MixGains gains[MAX_OUTPUT_CHANNELS];
-
if(!Counter)
- {
- for(j = 0;j < voice->DirectOut.Channels;j++)
- {
- gains[j].Target = targets[j];
- gains[j].Current = gains[j].Target;
- gains[j].Step = 0.0f;
- }
- }
- else
- {
- for(j = 0;j < voice->DirectOut.Channels;j++)
- {
- ALfloat diff;
- gains[j].Target = targets[j];
- gains[j].Current = currents[j];
- diff = gains[j].Target - gains[j].Current;
- if(fabsf(diff) >= GAIN_SILENCE_THRESHOLD)
- gains[j].Step = diff * Delta;
- else
- {
- gains[j].Current = gains[j].Target;
- gains[j].Step = 0.0f;
- }
- }
- }
-
+ memcpy(parms->Gains.Current, parms->Gains.Target,
+ sizeof(parms->Gains.Current));
MixSamples(samples, voice->DirectOut.Channels, voice->DirectOut.Buffer,
- gains, Counter, OutPos, DstBufferSize);
-
- for(j = 0;j < voice->DirectOut.Channels;j++)
- currents[j] = gains[j].Current;
+ parms->Gains.Current, parms->Gains.Target, Counter, OutPos, DstBufferSize
+ );
}
else
{
@@ -630,19 +589,20 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
}
else
{
+ ALfloat delta = 1.0f / (ALfloat)Counter;
ALfloat coeffdiff;
ALint delaydiff;
for(j = 0;j < IrSize;j++)
{
coeffdiff = parms->Hrtf.Target.Coeffs[j][0] - parms->Hrtf.Current.Coeffs[j][0];
- hrtfparams.Steps.Coeffs[j][0] = coeffdiff * Delta;
+ hrtfparams.Steps.Coeffs[j][0] = coeffdiff * delta;
coeffdiff = parms->Hrtf.Target.Coeffs[j][1] - parms->Hrtf.Current.Coeffs[j][1];
- hrtfparams.Steps.Coeffs[j][1] = coeffdiff * Delta;
+ hrtfparams.Steps.Coeffs[j][1] = coeffdiff * delta;
}
delaydiff = (ALint)(parms->Hrtf.Target.Delay[0] - parms->Hrtf.Current.Delay[0]);
- hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * Delta);
+ hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * delta);
delaydiff = (ALint)(parms->Hrtf.Target.Delay[1] - parms->Hrtf.Current.Delay[1]);
- hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * Delta);
+ hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * delta);
}
hrtfparams.Target = &parms->Hrtf.Target;
hrtfparams.Current = &parms->Hrtf.Current;
@@ -660,9 +620,6 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
for(send = 0;send < Device->NumAuxSends;send++)
{
SendParams *parms = &voice->Chan[chan].Send[send];
- ALfloat *restrict currents = parms->Gains.Current;
- const ALfloat *targets = parms->Gains.Target;
- MixGains gains[MAX_OUTPUT_CHANNELS];
const ALfloat *samples;
if(!voice->SendOut[send].Buffer)
@@ -674,39 +631,11 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
);
if(!Counter)
- {
- for(j = 0;j < voice->SendOut[send].Channels;j++)
- {
- gains[j].Target = targets[j];
- gains[j].Current = gains[j].Target;
- gains[j].Step = 0.0f;
- }
- }
- else
- {
- for(j = 0;j < voice->SendOut[send].Channels;j++)
- {
- ALfloat diff;
- gains[j].Target = targets[j];
- gains[j].Current = currents[j];
- diff = gains[j].Target - gains[j].Current;
- if(fabsf(diff) >= GAIN_SILENCE_THRESHOLD)
- gains[j].Step = diff * Delta;
- else
- {
- gains[j].Current = gains[j].Target;
- gains[j].Step = 0.0f;
- }
- }
- }
-
- MixSamples(samples,
- voice->SendOut[send].Channels, voice->SendOut[send].Buffer,
- gains, Counter, OutPos, DstBufferSize
+ memcpy(parms->Gains.Current, parms->Gains.Target,
+ sizeof(parms->Gains.Current));
+ MixSamples(samples, voice->SendOut[send].Channels, voice->SendOut[send].Buffer,
+ parms->Gains.Current, parms->Gains.Target, Counter, OutPos, DstBufferSize
);
-
- for(j = 0;j < voice->SendOut[send].Channels;j++)
- currents[j] = gains[j].Current;
}
}
/* Update positions */
@@ -716,6 +645,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
OutPos += DstBufferSize;
voice->Offset += DstBufferSize;
+ Counter = maxu(DstBufferSize, Counter) - DstBufferSize;
/* Handle looping sources */
while(1)
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index 3e726df5..a75ad002 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -172,17 +172,20 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize)
{
- ALfloat gain, step;
+ ALfloat gain, delta, step;
ALuint c;
+ delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f;
+
for(c = 0;c < OutChans;c++)
{
ALuint pos = 0;
- gain = Gains[c].Current;
- step = Gains[c].Step;
- if(step != 0.0f && Counter > 0)
+ gain = CurrentGains[c];
+ step = (TargetGains[c] - gain) * delta;
+ if(fabsf(step) > FLT_EPSILON)
{
ALuint minsize = minu(BufferSize, Counter);
for(;pos < minsize;pos++)
@@ -191,8 +194,8 @@ void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[B
gain += step;
}
if(pos == Counter)
- gain = Gains[c].Target;
- Gains[c].Current = gain;
+ gain = TargetGains[c];
+ CurrentGains[c] = gain;
}
if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 05e6f964..df449197 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -30,7 +30,8 @@ void MixDirectHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALu
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALuint BufferSize);
void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize);
void MixRow_C(ALfloat *OutBuffer, const ALfloat *Gains,
const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans,
ALuint InPos, ALuint BufferSize);
@@ -45,7 +46,8 @@ void MixDirectHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, A
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALuint BufferSize);
void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize);
void MixRow_SSE(ALfloat *OutBuffer, const ALfloat *Gains,
const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans,
ALuint InPos, ALuint BufferSize);
@@ -93,7 +95,8 @@ void MixDirectHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx,
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALuint BufferSize);
void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize);
void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains,
const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans,
ALuint InPos, ALuint BufferSize);
diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c
index 8c96aef1..6b506357 100644
--- a/Alc/mixer_neon.c
+++ b/Alc/mixer_neon.c
@@ -76,18 +76,21 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize)
{
- ALfloat gain, step;
+ ALfloat gain, delta, step;
float32x4_t gain4;
ALuint c;
+ delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f;
+
for(c = 0;c < OutChans;c++)
{
ALuint pos = 0;
- gain = Gains[c].Current;
- step = Gains[c].Step;
- if(step != 0.0f && Counter > 0)
+ gain = CurrentGains[c];
+ step = (TargetGains[c] - gain) * delta;
+ if(fabsf(step) > FLT_EPSILON)
{
ALuint minsize = minu(BufferSize, Counter);
/* Mix with applying gain steps in aligned multiples of 4. */
@@ -120,8 +123,8 @@ void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer
gain += step;
}
if(pos == Counter)
- gain = Gains[c].Target;
- Gains[c].Current = gain;
+ gain = TargetGains[c];
+ CurrentGains[c] = gain;
/* Mix until pos is aligned with 4 or the mix is done. */
minsize = minu(BufferSize, (pos+3)&~3);
diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c
index 24e0e545..6d18a638 100644
--- a/Alc/mixer_sse.c
+++ b/Alc/mixer_sse.c
@@ -192,18 +192,21 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
+ ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos,
+ ALuint BufferSize)
{
- ALfloat gain, step;
+ ALfloat gain, delta, step;
__m128 gain4;
ALuint c;
+ delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f;
+
for(c = 0;c < OutChans;c++)
{
ALuint pos = 0;
- gain = Gains[c].Current;
- step = Gains[c].Step;
- if(step != 0.0f && Counter > 0)
+ gain = CurrentGains[c];
+ step = (TargetGains[c] - gain) * delta;
+ if(fabsf(step) > FLT_EPSILON)
{
ALuint minsize = minu(BufferSize, Counter);
/* Mix with applying gain steps in aligned multiples of 4. */
@@ -238,8 +241,8 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)
gain += step;
}
if(pos == Counter)
- gain = Gains[c].Target;
- Gains[c].Current = gain;
+ gain = TargetGains[c];
+ CurrentGains[c] = gain;
/* Mix until pos is aligned with 4 or the mix is done. */
minsize = minu(BufferSize, (pos+3)&~3);