aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-29 21:58:37 -0700
committerChris Robinson <[email protected]>2019-05-29 21:58:37 -0700
commit893ffe9a84d497d38e6e472b0cffbd9c37e0c366 (patch)
treee86cb9f28857507a54aad958e8c4a9dd361c3e28
parent8af7b4c6e0ddaf4d66455702a7ede0c9036f3825 (diff)
Use span<FloatBufferLine> for MixSamples
-rw-r--r--Alc/effects/autowah.cpp19
-rw-r--r--Alc/effects/chorus.cpp14
-rw-r--r--Alc/effects/dedicated.cpp5
-rw-r--r--Alc/effects/echo.cpp6
-rw-r--r--Alc/effects/equalizer.cpp6
-rw-r--r--Alc/effects/fshifter.cpp4
-rw-r--r--Alc/effects/modulator.cpp10
-rw-r--r--Alc/effects/pshifter.cpp4
-rw-r--r--Alc/effects/reverb.cpp24
-rw-r--r--Alc/mixer/defs.h2
-rw-r--r--Alc/mixer/mixer_c.cpp19
-rw-r--r--Alc/mixer/mixer_neon.cpp19
-rw-r--r--Alc/mixer/mixer_sse.cpp19
-rw-r--r--Alc/mixvoice.cpp30
-rw-r--r--OpenAL32/Include/alu.h6
15 files changed, 91 insertions, 96 deletions
diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp
index 2b01f70a..2b0cb610 100644
--- a/Alc/effects/autowah.cpp
+++ b/Alc/effects/autowah.cpp
@@ -136,11 +136,9 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R
const ALfloat peak_gain = mPeakGain;
const ALfloat freq_min = mFreqMinNorm;
const ALfloat bandwidth = mBandwidthNorm;
- ALfloat env_delay;
- ALsizei c, i;
- env_delay = mEnvDelay;
- for(i = 0;i < samplesToDo;i++)
+ ALfloat env_delay{mEnvDelay};
+ for(ALsizei i{0};i < samplesToDo;i++)
{
ALfloat w0, sample, a;
@@ -158,8 +156,9 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R
}
mEnvDelay = env_delay;
+ const al::span<FloatBufferLine> output{samplesOut, samplesOut+numOutput};
ASSUME(numInput > 0);
- for(c = 0;c < numInput;++c)
+ for(ALsizei c{0};c < numInput;++c)
{
/* This effectively inlines BiquadFilter_setParams for a peaking
* filter and BiquadFilter_processC. The alpha and cosine components
@@ -167,10 +166,10 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R
* envelope. Because the filter changes for each sample, the
* coefficients are transient and don't need to be held.
*/
- ALfloat z1 = mChans[c].Filter.z1;
- ALfloat z2 = mChans[c].Filter.z2;
+ ALfloat z1{mChans[c].Filter.z1};
+ ALfloat z2{mChans[c].Filter.z2};
- for(i = 0;i < samplesToDo;i++)
+ for(ALsizei i{0};i < samplesToDo;i++)
{
const ALfloat alpha = mEnv[i].alpha;
const ALfloat cos_w0 = mEnv[i].cos_w0;
@@ -194,8 +193,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, numOutput, &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]),
- mChans[c].CurrentGains, mChans[c].TargetGains, samplesToDo, 0, samplesToDo);
+ MixSamples(mBufferOut, output, mChans[c].CurrentGains, mChans[c].TargetGains, samplesToDo,
+ 0, samplesToDo);
}
}
diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp
index e953d3e3..cdbb2036 100644
--- a/Alc/effects/chorus.cpp
+++ b/Alc/effects/chorus.cpp
@@ -205,10 +205,9 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
const ALsizei avgdelay{(mDelay + (FRACTIONONE>>1)) >> FRACTIONBITS};
ALfloat *RESTRICT delaybuf{mSampleBuffer.data()};
ALsizei offset{mOffset};
- ALsizei i, c;
- ALsizei base;
- for(base = 0;base < samplesToDo;)
+ const al::span<FloatBufferLine> output{samplesOut, samplesOut+numOutput};
+ for(ALsizei base{0};base < samplesToDo;)
{
const ALsizei todo = mini(256, samplesToDo-base);
ALint moddelays[2][256];
@@ -230,7 +229,7 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
}
mLfoOffset = (mLfoOffset+todo) % mLfoRange;
- for(i = 0;i < todo;i++)
+ for(ALsizei i{0};i < todo;i++)
{
// Feed the buffer's input first (necessary for delays < 1).
delaybuf[offset&bufmask] = samplesIn[0][base+i];
@@ -254,10 +253,9 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
offset++;
}
- for(c = 0;c < 2;c++)
- MixSamples(temps[c], numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mGains[c].Current,
- mGains[c].Target, samplesToDo-base, base, todo);
+ for(ALsizei c{0};c < 2;c++)
+ MixSamples(temps[c], output, mGains[c].Current, mGains[c].Target, samplesToDo-base,
+ base, todo);
base += todo;
}
diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp
index 7b44e392..b4eaa8e8 100644
--- a/Alc/effects/dedicated.cpp
+++ b/Alc/effects/dedicated.cpp
@@ -92,9 +92,8 @@ void DedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslo
void DedicatedState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, FloatBufferLine *RESTRICT samplesOut, const ALsizei numOutput)
{
- MixSamples(samplesIn[0].data(), numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mCurrentGains, mTargetGains,
- samplesToDo, 0, samplesToDo);
+ MixSamples(samplesIn[0].data(), {samplesOut, samplesOut+numOutput}, mCurrentGains,
+ mTargetGains, samplesToDo, 0, samplesToDo);
}
diff --git a/Alc/effects/echo.cpp b/Alc/effects/echo.cpp
index e684039d..e82e75bd 100644
--- a/Alc/effects/echo.cpp
+++ b/Alc/effects/echo.cpp
@@ -157,10 +157,10 @@ void EchoState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRI
mFilter.setComponents(z1, z2);
mOffset = offset;
+ const al::span<FloatBufferLine> output{samplesOut, samplesOut+numOutput};
for(ALsizei c{0};c < 2;c++)
- MixSamples(mTempBuffer[c], numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mGains[c].Current,
- mGains[c].Target, samplesToDo, 0, samplesToDo);
+ MixSamples(mTempBuffer[c], output, mGains[c].Current, mGains[c].Target, samplesToDo, 0,
+ samplesToDo);
}
diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp
index 53f8e153..f6be258b 100644
--- a/Alc/effects/equalizer.cpp
+++ b/Alc/effects/equalizer.cpp
@@ -160,6 +160,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
void EqualizerState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, FloatBufferLine *RESTRICT samplesOut, const ALsizei numOutput)
{
+ const al::span<FloatBufferLine> output{samplesOut, samplesOut+numOutput};
ASSUME(numInput > 0);
for(ALsizei c{0};c < numInput;c++)
{
@@ -168,9 +169,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, numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mChans[c].CurrentGains,
- mChans[c].TargetGains, samplesToDo, 0, samplesToDo);
+ MixSamples(mSampleBuffer, output, mChans[c].CurrentGains, mChans[c].TargetGains,
+ samplesToDo, 0, samplesToDo);
}
}
diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp
index 0b8d33e4..56068b06 100644
--- a/Alc/effects/fshifter.cpp
+++ b/Alc/effects/fshifter.cpp
@@ -198,8 +198,8 @@ void FshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE
}
/* Now, mix the processed sound data to the output. */
- MixSamples(BufferOut, numOutput, &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]),
- mCurrentGains, mTargetGains, maxi(samplesToDo, 512), 0, samplesToDo);
+ MixSamples(BufferOut, {samplesOut, samplesOut+numOutput}, mCurrentGains, mTargetGains,
+ maxi(samplesToDo, 512), 0, samplesToDo);
}
diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp
index ec0b6184..9b7abbb7 100644
--- a/Alc/effects/modulator.cpp
+++ b/Alc/effects/modulator.cpp
@@ -143,10 +143,10 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
void ModulatorState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, FloatBufferLine *RESTRICT samplesOut, const ALsizei numOutput)
{
- const ALsizei step = mStep;
- ALsizei base;
+ const ALsizei step{mStep};
- for(base = 0;base < samplesToDo;)
+ const al::span<FloatBufferLine> output{samplesOut, samplesOut+numOutput};
+ for(ALsizei base{0};base < samplesToDo;)
{
alignas(16) ALfloat modsamples[MAX_UPDATE_SAMPLES];
ALsizei td = mini(MAX_UPDATE_SAMPLES, samplesToDo-base);
@@ -165,8 +165,8 @@ void ModulatorState::process(const ALsizei samplesToDo, const FloatBufferLine *R
for(i = 0;i < td;i++)
temps[i] *= modsamples[i];
- MixSamples(temps, numOutput, &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]),
- mChans[c].CurrentGains, mChans[c].TargetGains, samplesToDo-base, base, td);
+ MixSamples(temps, output, mChans[c].CurrentGains, mChans[c].TargetGains,
+ samplesToDo-base, base, td);
}
base += td;
diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp
index a3e946c0..34f442bc 100644
--- a/Alc/effects/pshifter.cpp
+++ b/Alc/effects/pshifter.cpp
@@ -321,8 +321,8 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE
mCount = count;
/* Now, mix the processed sound data to the output. */
- MixSamples(bufferOut, numOutput, &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]),
- mCurrentGains, mTargetGains, maxi(samplesToDo, 512), 0, samplesToDo);
+ MixSamples(bufferOut, {samplesOut, samplesOut+numOutput}, mCurrentGains, mTargetGains,
+ maxi(samplesToDo, 512), 0, samplesToDo);
}
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp
index 74c9d3fc..5d2f25f9 100644
--- a/Alc/effects/reverb.cpp
+++ b/Alc/effects/reverb.cpp
@@ -375,7 +375,7 @@ struct ReverbState final : public EffectState {
alignas(16) FloatBufferLine mEarlyBuffer[NUM_LINES]{};
alignas(16) FloatBufferLine mLateBuffer[NUM_LINES]{};
- using MixOutT = void (ReverbState::*)(const ALsizei numOutput, FloatBufferLine *samplesOut,
+ using MixOutT = void (ReverbState::*)(const al::span<FloatBufferLine> samplesOut,
const ALsizei todo);
MixOutT mMixOut{&ReverbState::MixOutPlain};
@@ -383,7 +383,7 @@ struct ReverbState final : public EffectState {
std::array<std::array<BandSplitter,NUM_LINES>,2> mAmbiSplitter;
- void MixOutPlain(const ALsizei numOutput, FloatBufferLine *samplesOut, const ALsizei todo)
+ void MixOutPlain(const al::span<FloatBufferLine> samplesOut, const ALsizei todo)
{
ASSUME(todo > 0);
@@ -392,8 +392,7 @@ struct ReverbState final : public EffectState {
{
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
MixRowSamples(mTempSamples[0], A2B[c], mEarlyBuffer, 0, todo);
- MixSamples(mTempSamples[0].data(), numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mEarly.CurrentGain[c],
+ MixSamples(mTempSamples[0].data(), samplesOut, mEarly.CurrentGain[c],
mEarly.PanGain[c], todo, 0, todo);
}
@@ -401,13 +400,12 @@ struct ReverbState final : public EffectState {
{
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
MixRowSamples(mTempSamples[0], A2B[c], mLateBuffer, 0, todo);
- MixSamples(mTempSamples[0].data(), numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mLate.CurrentGain[c],
- mLate.PanGain[c], todo, 0, todo);
+ MixSamples(mTempSamples[0].data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
+ todo, 0, todo);
}
}
- void MixOutAmbiUp(const ALsizei numOutput, FloatBufferLine *samplesOut, const ALsizei todo)
+ void MixOutAmbiUp(const al::span<FloatBufferLine> samplesOut, const ALsizei todo)
{
ASSUME(todo > 0);
@@ -422,8 +420,7 @@ struct ReverbState final : public EffectState {
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
mAmbiSplitter[0][c].applyHfScale(mTempSamples[0].data(), hfscale, todo);
- MixSamples(mTempSamples[0].data(), numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mEarly.CurrentGain[c],
+ MixSamples(mTempSamples[0].data(), samplesOut, mEarly.CurrentGain[c],
mEarly.PanGain[c], todo, 0, todo);
}
@@ -435,9 +432,8 @@ struct ReverbState final : public EffectState {
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
mAmbiSplitter[1][c].applyHfScale(mTempSamples[0].data(), hfscale, todo);
- MixSamples(mTempSamples[0].data(), numOutput,
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mLate.CurrentGain[c],
- mLate.PanGain[c], todo, 0, todo);
+ MixSamples(mTempSamples[0].data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
+ todo, 0, todo);
}
}
@@ -1530,7 +1526,7 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
mFadeCount = fadeCount;
/* Finally, mix early reflections and late reverb. */
- (this->*mMixOut)(numOutput, samplesOut, samplesToDo);
+ (this->*mMixOut)({samplesOut, samplesOut+numOutput}, samplesToDo);
}
diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h
index e661b238..a86da8a1 100644
--- a/Alc/mixer/defs.h
+++ b/Alc/mixer/defs.h
@@ -32,7 +32,7 @@ template<typename TypeTag, typename InstTag>
const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen);
template<typename InstTag>
-void Mix_(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
+void Mix_(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer, ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
template<typename InstTag>
void MixRow_(FloatBufferLine &OutBuffer, const ALfloat *Gains, const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index d1bbd25e..9e8f2ad5 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -144,21 +144,20 @@ void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<>
-void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<CTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{&OutBuffer[c][OutPos]};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
+ ALfloat *RESTRICT dst{output.data()+OutPos};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
- const ALfloat diff{TargetGains[c] - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -170,11 +169,13 @@ void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *CurrentGains = gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index 300d421f..eaa09718 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -190,21 +190,20 @@ void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut
template<>
-void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{al::assume_aligned<16>(&OutBuffer[c][OutPos])};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
- const ALfloat diff{TargetGains[c] - gain};
+ ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -245,16 +244,18 @@ void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuf
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *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] += data[pos]*gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index ac1c9b18..0f8b905f 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -147,21 +147,20 @@ void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<>
-void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{al::assume_aligned<16>(&OutBuffer[c][OutPos])};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
- const ALfloat diff{TargetGains[c] - gain};
+ ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -199,16 +198,18 @@ void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuff
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *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] += data[pos]*gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index c9227919..d3b76492 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -800,23 +800,23 @@ 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.ChannelsPerOrder[0],
- &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[0]),
- parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize);
+ const auto outcount = static_cast<size_t>(voice->mDirect.ChannelsPerOrder[0]);
+ MixSamples(samples, {voice->mDirect.Buffer, outcount}, parms.Gains.Current,
+ TargetGains, Counter, OutPos, DstBufferSize);
ALfloat (&nfcsamples)[BUFFERSIZE] = Device->NfcSampleData;
- ALsizei chanoffset{voice->mDirect.ChannelsPerOrder[0]};
+ size_t chanoffset{outcount};
using FilterProc = void (NfcFilter::*)(float*,const float*,int);
auto apply_nfc = [voice,&parms,samples,TargetGains,DstBufferSize,Counter,OutPos,&chanoffset,&nfcsamples](FilterProc process, ALsizei order) -> void
{
- if(voice->mDirect.ChannelsPerOrder[order] < 1)
- return;
+ const auto outcount = static_cast<size_t>(
+ voice->mDirect.ChannelsPerOrder[order]);
+ if(outcount < 1) return;
(parms.NFCtrlFilter.*process)(nfcsamples, samples, DstBufferSize);
- MixSamples(nfcsamples, voice->mDirect.ChannelsPerOrder[order],
- &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[chanoffset]),
+ MixSamples(nfcsamples, {voice->mDirect.Buffer+chanoffset, outcount},
parms.Gains.Current+chanoffset, TargetGains+chanoffset, Counter,
OutPos, DstBufferSize);
- chanoffset += voice->mDirect.ChannelsPerOrder[order];
+ chanoffset += outcount;
};
apply_nfc(&NfcFilter::process1, 1);
apply_nfc(&NfcFilter::process2, 2);
@@ -826,9 +826,9 @@ 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.Channels,
- &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[0]),
- parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize);
+ const auto outcount = static_cast<size_t>(voice->mDirect.Channels);
+ MixSamples(samples, {voice->mDirect.Buffer, outcount}, parms.Gains.Current,
+ TargetGains, Counter, OutPos, DstBufferSize);
}
}
@@ -844,9 +844,9 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
const ALfloat *TargetGains{UNLIKELY(vstate==ALvoice::Stopping) ? SilentTarget :
parms.Gains.Target};
- MixSamples(samples, send.Channels,
- &reinterpret_cast<float(&)[BUFFERSIZE]>(send.Buffer[0]), parms.Gains.Current,
- TargetGains, Counter, OutPos, DstBufferSize);
+ const auto outcount = static_cast<size_t>(send.Channels);
+ MixSamples(samples, {send.Buffer, outcount}, parms.Gains.Current, TargetGains,
+ Counter, OutPos, DstBufferSize);
};
std::for_each(voice->mSend.begin(), voice->mSend.end(), mix_send);
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 49abe0f3..b6914c37 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -293,9 +293,9 @@ struct ALvoice {
void DeinitVoice(ALvoice *voice) noexcept;
-using MixerFunc = void(*)(const ALfloat *data, const ALsizei OutChans,
- ALfloat (*OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains,
- const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
+using MixerFunc = void(*)(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
+ ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
+ const ALsizei BufferSize);
using RowMixerFunc = void(*)(FloatBufferLine &OutBuffer, const ALfloat *gains,
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos,
const ALsizei BufferSize);