diff options
author | Chris Robinson <[email protected]> | 2019-08-26 09:16:20 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-26 09:16:20 -0700 |
commit | 7dbf69afa270417c28605a265cc2ec0a7c4fc939 (patch) | |
tree | ff6af7e2f556ecace074ef1ee968f088b5de2094 /alc/effects | |
parent | 12e6dc0cced98d8d4379dbdaa922381920d32df2 (diff) |
Use a span for effect state input
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/autowah.cpp | 23 | ||||
-rw-r--r-- | alc/effects/base.h | 2 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 4 | ||||
-rw-r--r-- | alc/effects/compressor.cpp | 12 | ||||
-rw-r--r-- | alc/effects/dedicated.cpp | 4 | ||||
-rw-r--r-- | alc/effects/distortion.cpp | 4 | ||||
-rw-r--r-- | alc/effects/echo.cpp | 4 | ||||
-rw-r--r-- | alc/effects/equalizer.cpp | 23 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 4 | ||||
-rw-r--r-- | alc/effects/modulator.cpp | 13 | ||||
-rw-r--r-- | alc/effects/null.cpp | 4 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 4 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 7 | ||||
-rw-r--r-- | alc/effects/vmorpher.cpp | 31 |
14 files changed, 72 insertions, 67 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 144798f8..f28cfd54 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -71,7 +71,7 @@ struct ALautowahState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ALautowahState) }; @@ -126,7 +126,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ALautowahState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { const ALfloat attack_rate = mAttackRate; const ALfloat release_rate = mReleaseRate; @@ -154,8 +154,8 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE } mEnvDelay = env_delay; - ASSUME(numInput > 0); - for(ALsizei c{0};c < numInput;++c) + auto chandata = std::addressof(mChans[0]); + for(const auto &insamples : samplesIn) { /* This effectively inlines BiquadFilter_setParams for a peaking * filter and BiquadFilter_processC. The alpha and cosine components @@ -163,8 +163,8 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE * 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{chandata->Filter.z1}; + ALfloat z2{chandata->Filter.z2}; for(size_t i{0u};i < samplesToDo;i++) { @@ -180,18 +180,19 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE a[1] = -2.0f * cos_w0; a[2] = 1.0f - alpha/res_gain; - input = samplesIn[c][i]; + input = insamples[i]; output = input*(b[0]/a[0]) + z1; z1 = input*(b[1]/a[0]) - output*(a[1]/a[0]) + z2; z2 = input*(b[2]/a[0]) - output*(a[2]/a[0]); mBufferOut[i] = output; } - mChans[c].Filter.z1 = z1; - mChans[c].Filter.z2 = z2; + chandata->Filter.z1 = z1; + chandata->Filter.z2 = z2; /* Now, mix the processed sound data to the output. */ - MixSamples({mBufferOut, samplesToDo}, samplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, samplesToDo, 0); + MixSamples({mBufferOut, samplesToDo}, samplesOut, chandata->CurrentGains, + chandata->TargetGains, samplesToDo, 0); + ++chandata; } } diff --git a/alc/effects/base.h b/alc/effects/base.h index 4d22c4c4..7bc170aa 100644 --- a/alc/effects/base.h +++ b/alc/effects/base.h @@ -159,7 +159,7 @@ struct EffectState : public al::intrusive_ref<EffectState> { virtual ALboolean deviceUpdate(const ALCdevice *device) = 0; virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0; - virtual void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) = 0; + virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) = 0; }; diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 37e29b8e..0d59c338 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -111,7 +111,7 @@ struct ChorusState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ChorusState) }; @@ -207,7 +207,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co } } -void ChorusState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { const auto bufmask = static_cast<ALsizei>(mSampleBuffer.size()-1); const ALfloat feedback{mFeedback}; diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp index e2f644ed..176e5a58 100644 --- a/alc/effects/compressor.cpp +++ b/alc/effects/compressor.cpp @@ -51,7 +51,7 @@ struct CompressorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(CompressorState) }; @@ -85,7 +85,7 @@ void CompressorState::update(const ALCcontext*, const ALeffectslot *slot, const } } -void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void CompressorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { for(size_t base{0u};base < samplesToDo;) { @@ -134,10 +134,10 @@ void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *R mEnvFollower = env; /* Now compress the signal amplitude to output. */ - ASSUME(numInput > 0); - for(ALsizei j{0};j < numInput;j++) + auto changains = std::addressof(mGain[0]); + for(const auto &input : samplesIn) { - const ALfloat *outgains{mGain[j]}; + const ALfloat *outgains{*(changains++)}; for(FloatBufferLine &output : samplesOut) { const ALfloat gain{*(outgains++)}; @@ -145,7 +145,7 @@ void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *R continue; for(size_t i{0u};i < td;i++) - output[base+i] += samplesIn[j][base+i] * gains[i] * gain; + output[base+i] += input[base+i] * gains[i] * gain; } } diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index 83cba773..02fdcc78 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -39,7 +39,7 @@ struct DedicatedState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(DedicatedState) }; @@ -86,7 +86,7 @@ void DedicatedState::update(const ALCcontext*, const ALeffectslot *slot, const E } } -void DedicatedState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void DedicatedState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains, mTargetGains, samplesToDo, 0); diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index ac6486cb..7dd43008 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -49,7 +49,7 @@ struct DistortionState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(DistortionState) }; @@ -93,7 +93,7 @@ void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain); } -void DistortionState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void DistortionState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { const ALfloat fc{mEdgeCoeff}; for(size_t base{0u};base < samplesToDo;) diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index 4a9ee1bc..d95011c2 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -59,7 +59,7 @@ struct EchoState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(EchoState) }; @@ -117,7 +117,7 @@ void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, cons ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void EchoState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void EchoState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1); ALfloat *RESTRICT delaybuf{mSampleBuffer.data()}; diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp index 05818ebf..929bff14 100644 --- a/alc/effects/equalizer.cpp +++ b/alc/effects/equalizer.cpp @@ -93,7 +93,7 @@ struct EqualizerState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(EqualizerState) }; @@ -157,18 +157,19 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void EqualizerState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void EqualizerState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { - ASSUME(numInput > 0); - for(ALsizei c{0};c < numInput;c++) + auto chandata = std::addressof(mChans[0]); + for(const auto &input : samplesIn) { - mChans[c].filter[0].process(mSampleBuffer, samplesIn[c].data(), samplesToDo); - mChans[c].filter[1].process(mSampleBuffer, mSampleBuffer, samplesToDo); - mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo); - mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo); - - MixSamples({mSampleBuffer, samplesToDo}, samplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, samplesToDo, 0); + chandata->filter[0].process(mSampleBuffer, input.data(), samplesToDo); + chandata->filter[1].process(mSampleBuffer, mSampleBuffer, samplesToDo); + chandata->filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo); + chandata->filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo); + + MixSamples({mSampleBuffer, samplesToDo}, samplesOut, chandata->CurrentGains, + chandata->TargetGains, samplesToDo, 0); + ++chandata; } } diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 6983ae42..351b138f 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -85,7 +85,7 @@ struct FshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(FshifterState) }; @@ -160,7 +160,7 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void FshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void FshifterState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { static constexpr complex_d complex_zero{0.0, 0.0}; ALfloat *RESTRICT BufferOut = mBufferOut; diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index a4a8e5c9..ffb1c381 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -91,7 +91,7 @@ struct ModulatorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ModulatorState) }; @@ -138,7 +138,7 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void ModulatorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ModulatorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { for(size_t base{0u};base < samplesToDo;) { @@ -149,17 +149,18 @@ void ModulatorState::process(const size_t samplesToDo, const FloatBufferLine *RE mIndex += (mStep*td) & WAVEFORM_FRACMASK; mIndex &= WAVEFORM_FRACMASK; - ASSUME(numInput > 0); - for(ALsizei c{0};c < numInput;c++) + auto chandata = std::addressof(mChans[0]); + for(const auto &input : samplesIn) { alignas(16) ALfloat temps[MAX_UPDATE_SAMPLES]; - mChans[c].Filter.process(temps, &samplesIn[c][base], td); + chandata->Filter.process(temps, &input[base], td); for(size_t i{0u};i < td;i++) temps[i] *= modsamples[i]; - MixSamples({temps, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, + MixSamples({temps, td}, samplesOut, chandata->CurrentGains, chandata->TargetGains, samplesToDo-base, base); + ++chandata; } base += td; diff --git a/alc/effects/null.cpp b/alc/effects/null.cpp index c833a73a..e0497296 100644 --- a/alc/effects/null.cpp +++ b/alc/effects/null.cpp @@ -20,7 +20,7 @@ struct NullState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(NullState) }; @@ -58,7 +58,7 @@ void NullState::update(const ALCcontext* /*context*/, const ALeffectslot* /*slot * not replace it. */ void NullState::process(const size_t/*samplesToDo*/, - const FloatBufferLine *RESTRICT /*samplesIn*/, const ALsizei /*numInput*/, + const al::span<const FloatBufferLine> /*samplesIn*/, const al::span<FloatBufferLine> /*samplesOut*/) { } diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index a3f162c9..9d011b12 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -118,7 +118,7 @@ struct PshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(PshifterState) }; @@ -161,7 +161,7 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void PshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void PshifterState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { /* Pitch shifter engine based on the work of Stephan Bernsee. * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 5d9dbf81..4cd9124e 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -483,7 +483,7 @@ struct ReverbState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ReverbState) }; @@ -1440,18 +1440,19 @@ void ReverbState::lateFaded(const size_t offset, const size_t todo, const ALfloa VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, temps, todo); } -void ReverbState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { size_t offset{mOffset}; ASSUME(samplesToDo > 0); /* Convert B-Format to A-Format for processing. */ + const size_t numInput{samplesIn.size()}; const al::span<float> tmpspan{mTempLine.data(), samplesToDo}; for(size_t c{0u};c < NUM_LINES;c++) { std::fill(tmpspan.begin(), tmpspan.end(), 0.0f); - MixRowSamples(tmpspan, {B2A[c], B2A[c]+numInput}, samplesIn->data(), samplesIn->size()); + MixRowSamples(tmpspan, {B2A[c], numInput}, samplesIn[0].data(), samplesIn[0].size()); /* Band-pass the incoming samples and feed the initial delay line. */ mFilter[c].Lp.process(mTempLine.data(), mTempLine.data(), samplesToDo); diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index a75420a3..a3524371 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -137,7 +137,7 @@ struct VmorpherState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; static std::array<FormantFilter,4> getFiltersByPhoneme(ALenum phoneme, ALfloat frequency, ALfloat pitch); @@ -244,7 +244,7 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void VmorpherState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void VmorpherState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) { /* Following the EFX specification for a conformant implementation which describes * the effect as a pair of 4-band formant filters blended together using an LFO. @@ -258,34 +258,35 @@ void VmorpherState::process(const size_t samplesToDo, const FloatBufferLine *RES mIndex += (mStep * td) & WAVEFORM_FRACMASK; mIndex &= WAVEFORM_FRACMASK; - ASSUME(numInput > 0); - for(ALsizei c{0};c < numInput;c++) + auto chandata = std::addressof(mChans[0]); + for(const auto &input : samplesIn) { std::fill_n(std::begin(mSampleBufferA), td, 0.0f); std::fill_n(std::begin(mSampleBufferB), td, 0.0f); - auto& vowelA = mChans[c].Formants[VOWEL_A_INDEX]; - auto& vowelB = mChans[c].Formants[VOWEL_B_INDEX]; + auto& vowelA = chandata->Formants[VOWEL_A_INDEX]; + auto& vowelB = chandata->Formants[VOWEL_B_INDEX]; /* Process first vowel. */ - vowelA[0].process(&samplesIn[c][base], mSampleBufferA, td); - vowelA[1].process(&samplesIn[c][base], mSampleBufferA, td); - vowelA[2].process(&samplesIn[c][base], mSampleBufferA, td); - vowelA[3].process(&samplesIn[c][base], mSampleBufferA, td); + vowelA[0].process(&input[base], mSampleBufferA, td); + vowelA[1].process(&input[base], mSampleBufferA, td); + vowelA[2].process(&input[base], mSampleBufferA, td); + vowelA[3].process(&input[base], mSampleBufferA, td); /* Process second vowel. */ - vowelB[0].process(&samplesIn[c][base], mSampleBufferB, td); - vowelB[1].process(&samplesIn[c][base], mSampleBufferB, td); - vowelB[2].process(&samplesIn[c][base], mSampleBufferB, td); - vowelB[3].process(&samplesIn[c][base], mSampleBufferB, td); + vowelB[0].process(&input[base], mSampleBufferB, td); + vowelB[1].process(&input[base], mSampleBufferB, td); + vowelB[2].process(&input[base], mSampleBufferB, td); + vowelB[3].process(&input[base], mSampleBufferB, td); alignas(16) ALfloat blended[MAX_UPDATE_SAMPLES]; for(size_t i{0u};i < td;i++) blended[i] = lerp(mSampleBufferA[i], mSampleBufferB[i], lfo[i]); /* Now, mix the processed sound data to the output. */ - MixSamples({blended, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, + MixSamples({blended, td}, samplesOut, chandata->CurrentGains, chandata->TargetGains, samplesToDo-base, base); + ++chandata; } base += td; |