Pass a span for the Mix function's input
This commit is contained in:
@@ -314,9 +314,9 @@ struct ALvoice {
|
||||
};
|
||||
|
||||
|
||||
using MixerFunc = void(*)(const ALfloat *InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize);
|
||||
using MixerFunc = void(*)(const al::span<const float> InSamples,
|
||||
const al::span<FloatBufferLine> OutBuffer, float *CurrentGains, const float *TargetGains,
|
||||
const ALsizei Counter, const ALsizei OutPos);
|
||||
using RowMixerFunc = void(*)(const al::span<float> OutBuffer, const al::span<const float> Gains,
|
||||
const float *InSamples, const size_t InStride);
|
||||
using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
|
||||
@@ -190,8 +190,8 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R
|
||||
mChans[c].Filter.z2 = z2;
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples(mBufferOut, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
samplesToDo, 0, samplesToDo);
|
||||
MixSamples({mBufferOut, mBufferOut+samplesToDo}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,9 +218,8 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
|
||||
for(ALsizei base{0};base < samplesToDo;)
|
||||
{
|
||||
const ALsizei todo = mini(256, samplesToDo-base);
|
||||
ALint moddelays[2][256];
|
||||
alignas(16) ALfloat temps[2][256];
|
||||
|
||||
ALint moddelays[2][256];
|
||||
if(mWaveform == WaveForm::Sinusoid)
|
||||
{
|
||||
GetSinusoidDelays(moddelays[0], mLfoOffset, mLfoRange, mLfoScale, mDepth, mDelay,
|
||||
@@ -237,6 +236,7 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
|
||||
}
|
||||
mLfoOffset = (mLfoOffset+todo) % mLfoRange;
|
||||
|
||||
alignas(16) ALfloat temps[2][256];
|
||||
for(ALsizei i{0};i < todo;i++)
|
||||
{
|
||||
// Feed the buffer's input first (necessary for delays < 1).
|
||||
@@ -262,8 +262,8 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
|
||||
}
|
||||
|
||||
for(ALsizei c{0};c < 2;c++)
|
||||
MixSamples(temps[c], samplesOut, mGains[c].Current, mGains[c].Target, samplesToDo-base,
|
||||
base, todo);
|
||||
MixSamples({temps[c], temps[c]+todo}, samplesOut, mGains[c].Current, mGains[c].Target,
|
||||
samplesToDo-base, base);
|
||||
|
||||
base += todo;
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ void DedicatedState::update(const ALCcontext*, const ALeffectslot *slot, const E
|
||||
|
||||
void DedicatedState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
MixSamples(samplesIn[0].data(), samplesOut, mCurrentGains, mTargetGains, samplesToDo, 0,
|
||||
samplesToDo);
|
||||
MixSamples({samplesIn[0].data(), samplesIn[0].data()+samplesToDo}, samplesOut, mCurrentGains,
|
||||
mTargetGains, samplesToDo, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ void EchoState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRI
|
||||
mOffset = offset;
|
||||
|
||||
for(ALsizei c{0};c < 2;c++)
|
||||
MixSamples(mTempBuffer[c], samplesOut, mGains[c].Current, mGains[c].Target, samplesToDo, 0,
|
||||
samplesToDo);
|
||||
MixSamples({mTempBuffer[c], mTempBuffer[c]+samplesToDo}, samplesOut, mGains[c].Current,
|
||||
mGains[c].Target, samplesToDo, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -167,8 +167,8 @@ void EqualizerState::process(const ALsizei samplesToDo, const FloatBufferLine *R
|
||||
mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
|
||||
MixSamples(mSampleBuffer, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
samplesToDo, 0, samplesToDo);
|
||||
MixSamples({mSampleBuffer, mSampleBuffer+samplesToDo}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,8 @@ void FshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE
|
||||
}
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples(BufferOut, samplesOut, mGains[c].Current, mGains[c].Target,
|
||||
maxi(samplesToDo, 512), 0, samplesToDo);
|
||||
MixSamples({BufferOut, BufferOut+samplesToDo}, samplesOut, mGains[c].Current,
|
||||
mGains[c].Target, maxi(samplesToDo, 512), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,8 +160,8 @@ void ModulatorState::process(const ALsizei samplesToDo, const FloatBufferLine *R
|
||||
for(i = 0;i < td;i++)
|
||||
temps[i] *= modsamples[i];
|
||||
|
||||
MixSamples(temps, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
samplesToDo-base, base, td);
|
||||
MixSamples({temps, temps+td}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo-base, base);
|
||||
}
|
||||
|
||||
base += td;
|
||||
|
||||
@@ -285,8 +285,8 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE
|
||||
mCount = count;
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples(bufferOut, samplesOut, mCurrentGains, mTargetGains, maxi(samplesToDo, 512), 0,
|
||||
samplesToDo);
|
||||
MixSamples({bufferOut, bufferOut+samplesToDo}, samplesOut, mCurrentGains, mTargetGains,
|
||||
maxi(samplesToDo, 512), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -427,16 +427,16 @@ struct ReverbState final : public EffectState {
|
||||
std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
|
||||
MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mEarlySamples[0].data(),
|
||||
mEarlySamples[0].size());
|
||||
MixSamples(mTempLine.data(), samplesOut, mEarly.CurrentGain[c],
|
||||
mEarly.PanGain[c], counter, offset, todo);
|
||||
MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], counter,
|
||||
offset);
|
||||
}
|
||||
for(size_t c{0u};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
|
||||
MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mLateSamples[0].data(),
|
||||
mLateSamples[0].size());
|
||||
MixSamples(mTempLine.data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
|
||||
counter, offset, todo);
|
||||
MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], counter,
|
||||
offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,10 +456,10 @@ struct ReverbState final : public EffectState {
|
||||
* higher-order output.
|
||||
*/
|
||||
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
|
||||
mAmbiSplitter[0][c].applyHfScale(mTempLine.data(), hfscale, todo);
|
||||
mAmbiSplitter[0][c].applyHfScale(tmpspan.data(), hfscale, todo);
|
||||
|
||||
MixSamples(mTempLine.data(), samplesOut, mEarly.CurrentGain[c],
|
||||
mEarly.PanGain[c], counter, offset, todo);
|
||||
MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], counter,
|
||||
offset);
|
||||
}
|
||||
for(size_t c{0u};c < NUM_LINES;c++)
|
||||
{
|
||||
@@ -468,10 +468,10 @@ struct ReverbState final : public EffectState {
|
||||
mLateSamples[0].size());
|
||||
|
||||
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
|
||||
mAmbiSplitter[1][c].applyHfScale(mTempLine.data(), hfscale, todo);
|
||||
mAmbiSplitter[1][c].applyHfScale(tmpspan.data(), hfscale, todo);
|
||||
|
||||
MixSamples(mTempLine.data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
|
||||
counter, offset, todo);
|
||||
MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], counter,
|
||||
offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,14 +279,13 @@ void VmorpherState::process(const ALsizei samplesToDo, const FloatBufferLine *RE
|
||||
vowelB[2].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
vowelB[3].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
|
||||
alignas(16) ALfloat samplesBlended[MAX_UPDATE_SAMPLES];
|
||||
|
||||
for (ALsizei i{0};i < td;i++)
|
||||
samplesBlended[i] = lerp(mSampleBufferA[i], mSampleBufferB[i], lfo[i]);
|
||||
alignas(16) ALfloat blended[MAX_UPDATE_SAMPLES];
|
||||
for(ALsizei i{0};i < td;i++)
|
||||
blended[i] = lerp(mSampleBufferA[i], mSampleBufferB[i], lfo[i]);
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples(samplesBlended, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
samplesToDo-base, base, td);
|
||||
MixSamples({blended, blended+td}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo-base, base);
|
||||
}
|
||||
|
||||
base += td;
|
||||
|
||||
+2
-3
@@ -30,9 +30,8 @@ template<ResampleType TypeTag, InstSetType InstTag>
|
||||
const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen);
|
||||
|
||||
template<InstSetType InstTag>
|
||||
void Mix_(const float *InSamples, const al::span<FloatBufferLine> OutBuffer, float *CurrentGains,
|
||||
const float *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize);
|
||||
void Mix_(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos);
|
||||
template<InstSetType InstTag>
|
||||
void MixRow_(const al::span<float> OutBuffer, const al::span<const float> Gains,
|
||||
const float *InSamples, const size_t InStride);
|
||||
|
||||
+11
-13
@@ -142,31 +142,29 @@ void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
|
||||
|
||||
template<>
|
||||
void Mix_<CTag>(const float *InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize)
|
||||
void Mix_<CTag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
|
||||
const bool reached_target{InSamples.size() >= static_cast<size_t>(Counter)};
|
||||
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
|
||||
for(FloatBufferLine &output : OutBuffer)
|
||||
{
|
||||
ALfloat *RESTRICT dst{output.data()+OutPos};
|
||||
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
|
||||
ALfloat gain{*CurrentGains};
|
||||
const ALfloat diff{*TargetGains - gain};
|
||||
|
||||
ALsizei pos{0};
|
||||
auto in_iter = InSamples.begin();
|
||||
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
|
||||
{
|
||||
ALsizei minsize{mini(BufferSize, Counter)};
|
||||
const ALfloat step{diff * delta};
|
||||
ALfloat step_count{0.0f};
|
||||
for(;pos < minsize;pos++)
|
||||
while(in_iter != min_end)
|
||||
{
|
||||
dst[pos] += InSamples[pos] * (gain + step*step_count);
|
||||
*(dst++) += *(in_iter++) * (gain + step*step_count);
|
||||
step_count += 1.0f;
|
||||
}
|
||||
if(pos == Counter)
|
||||
if(reached_target)
|
||||
gain = *TargetGains;
|
||||
else
|
||||
gain += step*step_count;
|
||||
@@ -177,8 +175,8 @@ void Mix_<CTag>(const float *InSamples, const al::span<FloatBufferLine> OutBuffe
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
for(;pos < BufferSize;pos++)
|
||||
dst[pos] += InSamples[pos]*gain;
|
||||
while(in_iter != InSamples.end())
|
||||
*(dst++) += *(in_iter++) * gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-29
@@ -189,27 +189,27 @@ void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut
|
||||
|
||||
|
||||
template<>
|
||||
void Mix_<NEONTag>(const float *InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize)
|
||||
void Mix_<NEONTag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f};
|
||||
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
|
||||
const bool reached_target{InSamples.size() >= static_cast<size_t>(Counter)};
|
||||
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
|
||||
const auto aligned_end = minz(InSamples.size(), (min_end-InSamples.begin()+3) & ~3) +
|
||||
InSamples.begin();
|
||||
for(FloatBufferLine &output : OutBuffer)
|
||||
{
|
||||
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
|
||||
ALfloat gain{*CurrentGains};
|
||||
const ALfloat diff{*TargetGains - gain};
|
||||
|
||||
ALsizei pos{0};
|
||||
auto in_iter = InSamples.begin();
|
||||
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
|
||||
{
|
||||
ALsizei minsize{mini(BufferSize, Counter)};
|
||||
const ALfloat step{diff * delta};
|
||||
ALfloat step_count{0.0f};
|
||||
/* Mix with applying gain steps in aligned multiples of 4. */
|
||||
if LIKELY(minsize > 3)
|
||||
if(ptrdiff_t todo{(min_end-in_iter) >> 2})
|
||||
{
|
||||
const float32x4_t four4{vdupq_n_f32(4.0f)};
|
||||
const float32x4_t step4{vdupq_n_f32(step)};
|
||||
@@ -220,15 +220,13 @@ void Mix_<NEONTag>(const float *InSamples, const al::span<FloatBufferLine> OutBu
|
||||
vsetq_lane_f32(3.0f, vdupq_n_f32(0.0f), 3),
|
||||
2), 1), 0
|
||||
)};
|
||||
ALsizei todo{minsize >> 2};
|
||||
|
||||
do {
|
||||
const float32x4_t val4 = vld1q_f32(&InSamples[pos]);
|
||||
float32x4_t dry4 = vld1q_f32(&dst[pos]);
|
||||
const float32x4_t val4 = vld1q_f32(in_iter);
|
||||
float32x4_t dry4 = vld1q_f32(dst);
|
||||
dry4 = vmlaq_f32(dry4, val4, vmlaq_f32(gain4, step4, step_count4));
|
||||
step_count4 = vaddq_f32(step_count4, four4);
|
||||
vst1q_f32(&dst[pos], dry4);
|
||||
pos += 4;
|
||||
vst1q_f32(dst, dry4);
|
||||
in_iter += 4; dst += 4;
|
||||
} while(--todo);
|
||||
/* NOTE: step_count4 now represents the next four counts after
|
||||
* the last four mixed samples, so the lowest element
|
||||
@@ -237,41 +235,39 @@ void Mix_<NEONTag>(const float *InSamples, const al::span<FloatBufferLine> OutBu
|
||||
step_count = vgetq_lane_f32(step_count4, 0);
|
||||
}
|
||||
/* Mix with applying left over gain steps that aren't aligned multiples of 4. */
|
||||
for(;pos < minsize;pos++)
|
||||
while(in_iter != min_end)
|
||||
{
|
||||
dst[pos] += InSamples[pos]*(gain + step*step_count);
|
||||
*(dst++) += *(in_iter++) * (gain + step*step_count);
|
||||
step_count += 1.0f;
|
||||
}
|
||||
if(pos == Counter)
|
||||
if(reached_target)
|
||||
gain = *TargetGains;
|
||||
else
|
||||
gain += step*step_count;
|
||||
*CurrentGains = gain;
|
||||
|
||||
/* Mix until pos is aligned with 4 or the mix is done. */
|
||||
minsize = mini(BufferSize, (pos+3)&~3);
|
||||
for(;pos < minsize;pos++)
|
||||
dst[pos] += InSamples[pos]*gain;
|
||||
while(in_iter != aligned_end)
|
||||
*(dst++) += *(in_iter++) * gain;
|
||||
}
|
||||
++CurrentGains;
|
||||
++TargetGains;
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
if LIKELY(BufferSize-pos > 3)
|
||||
if(ptrdiff_t todo{(InSamples.end()-in_iter) >> 2})
|
||||
{
|
||||
ALsizei todo{(BufferSize-pos) >> 2};
|
||||
const float32x4_t gain4 = vdupq_n_f32(gain);
|
||||
do {
|
||||
const float32x4_t val4 = vld1q_f32(&InSamples[pos]);
|
||||
float32x4_t dry4 = vld1q_f32(&dst[pos]);
|
||||
const float32x4_t val4 = vld1q_f32(in_iter);
|
||||
float32x4_t dry4 = vld1q_f32(dst);
|
||||
dry4 = vmlaq_f32(dry4, val4, gain4);
|
||||
vst1q_f32(&dst[pos], dry4);
|
||||
pos += 4;
|
||||
vst1q_f32(dst, dry4);
|
||||
in_iter += 4; dst += 4;
|
||||
} while(--todo);
|
||||
}
|
||||
for(;pos < BufferSize;pos++)
|
||||
dst[pos] += InSamples[pos]*gain;
|
||||
while(in_iter != InSamples.end())
|
||||
*(dst++) += *(in_iter++) * gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-27
@@ -145,43 +145,42 @@ void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
|
||||
|
||||
template<>
|
||||
void Mix_<SSETag>(const float *InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize)
|
||||
void Mix_<SSETag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
float *CurrentGains, const float *TargetGains, const ALsizei Counter, const ALsizei OutPos)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
|
||||
const bool reached_target{InSamples.size() >= static_cast<size_t>(Counter)};
|
||||
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
|
||||
const auto aligned_end = minz(InSamples.size(), (min_end-InSamples.begin()+3) & ~3) +
|
||||
InSamples.begin();
|
||||
for(FloatBufferLine &output : OutBuffer)
|
||||
{
|
||||
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
|
||||
ALfloat gain{*CurrentGains};
|
||||
const ALfloat diff{*TargetGains - gain};
|
||||
|
||||
ALsizei pos{0};
|
||||
auto in_iter = InSamples.begin();
|
||||
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
|
||||
{
|
||||
ALsizei minsize{mini(BufferSize, Counter)};
|
||||
const ALfloat step{diff * delta};
|
||||
ALfloat step_count{0.0f};
|
||||
/* Mix with applying gain steps in aligned multiples of 4. */
|
||||
if LIKELY(minsize > 3)
|
||||
if(ptrdiff_t todo{(min_end-in_iter) >> 2})
|
||||
{
|
||||
const __m128 four4{_mm_set1_ps(4.0f)};
|
||||
const __m128 step4{_mm_set1_ps(step)};
|
||||
const __m128 gain4{_mm_set1_ps(gain)};
|
||||
__m128 step_count4{_mm_setr_ps(0.0f, 1.0f, 2.0f, 3.0f)};
|
||||
ALsizei todo{minsize >> 2};
|
||||
do {
|
||||
const __m128 val4{_mm_load_ps(&InSamples[pos])};
|
||||
__m128 dry4{_mm_load_ps(&dst[pos])};
|
||||
const __m128 val4{_mm_load_ps(in_iter)};
|
||||
__m128 dry4{_mm_load_ps(dst)};
|
||||
#define MLA4(x, y, z) _mm_add_ps(x, _mm_mul_ps(y, z))
|
||||
/* dry += val * (gain + step*step_count) */
|
||||
dry4 = MLA4(dry4, val4, MLA4(gain4, step4, step_count4));
|
||||
#undef MLA4
|
||||
_mm_store_ps(&dst[pos], dry4);
|
||||
_mm_store_ps(dst, dry4);
|
||||
step_count4 = _mm_add_ps(step_count4, four4);
|
||||
pos += 4;
|
||||
in_iter += 4; dst += 4;
|
||||
} while(--todo);
|
||||
/* NOTE: step_count4 now represents the next four counts after
|
||||
* the last four mixed samples, so the lowest element
|
||||
@@ -190,41 +189,39 @@ void Mix_<SSETag>(const float *InSamples, const al::span<FloatBufferLine> OutBuf
|
||||
step_count = _mm_cvtss_f32(step_count4);
|
||||
}
|
||||
/* Mix with applying left over gain steps that aren't aligned multiples of 4. */
|
||||
for(;pos < minsize;pos++)
|
||||
while(in_iter != min_end)
|
||||
{
|
||||
dst[pos] += InSamples[pos]*(gain + step*step_count);
|
||||
*(dst++) += *(in_iter++) * (gain + step*step_count);
|
||||
step_count += 1.0f;
|
||||
}
|
||||
if(pos == Counter)
|
||||
if(reached_target)
|
||||
gain = *TargetGains;
|
||||
else
|
||||
gain += step*step_count;
|
||||
*CurrentGains = gain;
|
||||
|
||||
/* Mix until pos is aligned with 4 or the mix is done. */
|
||||
minsize = mini(BufferSize, (pos+3)&~3);
|
||||
for(;pos < minsize;pos++)
|
||||
dst[pos] += InSamples[pos]*gain;
|
||||
while(in_iter != aligned_end)
|
||||
*(dst++) += *(in_iter++) * gain;
|
||||
}
|
||||
++CurrentGains;
|
||||
++TargetGains;
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
if LIKELY(BufferSize-pos > 3)
|
||||
if(ptrdiff_t todo{(InSamples.end()-in_iter) >> 2})
|
||||
{
|
||||
ALsizei todo{(BufferSize-pos) >> 2};
|
||||
const __m128 gain4{_mm_set1_ps(gain)};
|
||||
do {
|
||||
const __m128 val4{_mm_load_ps(&InSamples[pos])};
|
||||
__m128 dry4{_mm_load_ps(&dst[pos])};
|
||||
const __m128 val4{_mm_load_ps(in_iter)};
|
||||
__m128 dry4{_mm_load_ps(dst)};
|
||||
dry4 = _mm_add_ps(dry4, _mm_mul_ps(val4, gain4));
|
||||
_mm_store_ps(&dst[pos], dry4);
|
||||
pos += 4;
|
||||
_mm_store_ps(dst, dry4);
|
||||
in_iter += 4; dst += 4;
|
||||
} while(--todo);
|
||||
}
|
||||
for(;pos < BufferSize;pos++)
|
||||
dst[pos] += InSamples[pos]*gain;
|
||||
while(in_iter != InSamples.end())
|
||||
*(dst++) += *(in_iter++) * gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -762,19 +762,21 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
||||
SilentTarget : parms.Gains.Target};
|
||||
|
||||
const size_t outcount{Device->NumChannelsPerOrder[0]};
|
||||
MixSamples(samples, voice->mDirect.Buffer.first(outcount), parms.Gains.Current,
|
||||
TargetGains, Counter, OutPos, DstBufferSize);
|
||||
MixSamples({samples, samples+DstBufferSize},
|
||||
voice->mDirect.Buffer.first(outcount), parms.Gains.Current, TargetGains,
|
||||
Counter, OutPos);
|
||||
|
||||
ALfloat (&nfcsamples)[BUFFERSIZE] = Device->NfcSampleData;
|
||||
const al::span<float> nfcsamples{Device->NfcSampleData,
|
||||
static_cast<size_t>(DstBufferSize)};
|
||||
size_t chanoffset{outcount};
|
||||
using FilterProc = void (NfcFilter::*)(float*,const float*,int);
|
||||
auto apply_nfc = [voice,&parms,samples,TargetGains,DstBufferSize,Counter,OutPos,&chanoffset,&nfcsamples](const FilterProc process, const size_t outcount) -> void
|
||||
auto apply_nfc = [voice,&parms,samples,TargetGains,DstBufferSize,Counter,OutPos,&chanoffset,nfcsamples](const FilterProc process, const size_t outcount) -> void
|
||||
{
|
||||
if(outcount < 1) return;
|
||||
(parms.NFCtrlFilter.*process)(nfcsamples, samples, DstBufferSize);
|
||||
(parms.NFCtrlFilter.*process)(nfcsamples.data(), samples, DstBufferSize);
|
||||
MixSamples(nfcsamples, voice->mDirect.Buffer.subspan(chanoffset, outcount),
|
||||
parms.Gains.Current+chanoffset, TargetGains+chanoffset, Counter,
|
||||
OutPos, DstBufferSize);
|
||||
OutPos);
|
||||
chanoffset += outcount;
|
||||
};
|
||||
apply_nfc(&NfcFilter::process1, Device->NumChannelsPerOrder[1]);
|
||||
@@ -785,8 +787,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
||||
{
|
||||
const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ?
|
||||
SilentTarget : parms.Gains.Target};
|
||||
MixSamples(samples, voice->mDirect.Buffer, parms.Gains.Current, TargetGains,
|
||||
Counter, OutPos, DstBufferSize);
|
||||
MixSamples({samples, samples+DstBufferSize}, voice->mDirect.Buffer,
|
||||
parms.Gains.Current, TargetGains, Counter, OutPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,8 +804,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
||||
|
||||
const ALfloat *TargetGains{UNLIKELY(vstate==ALvoice::Stopping) ? SilentTarget :
|
||||
parms.Gains.Target};
|
||||
MixSamples(samples, voice->mSend[send].Buffer, parms.Gains.Current, TargetGains,
|
||||
Counter, OutPos, DstBufferSize);
|
||||
MixSamples({samples, samples+DstBufferSize}, voice->mSend[send].Buffer,
|
||||
parms.Gains.Current, TargetGains, Counter, OutPos);
|
||||
};
|
||||
}
|
||||
/* Update positions */
|
||||
|
||||
Reference in New Issue
Block a user