diff options
author | Chris Robinson <[email protected]> | 2023-10-15 02:38:20 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-10-15 02:38:20 -0700 |
commit | bfee94dfec64dd22ad8d985e71803fbe411f7a1a (patch) | |
tree | 1336374fa65a1eed4dcc790b4707dde13341a765 | |
parent | 5619de5ca05684656f32eafd8cfc987fb6161d97 (diff) |
Use a span for a known array length instead of a raw pointer
-rw-r--r-- | alc/alu.cpp | 28 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 4 | ||||
-rw-r--r-- | alc/effects/convolution.cpp | 6 | ||||
-rw-r--r-- | alc/effects/dedicated.cpp | 2 | ||||
-rw-r--r-- | alc/effects/distortion.cpp | 2 | ||||
-rw-r--r-- | alc/effects/echo.cpp | 4 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 4 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 2 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 8 | ||||
-rw-r--r-- | core/mixer.cpp | 7 | ||||
-rw-r--r-- | core/mixer.h | 4 |
11 files changed, 35 insertions, 36 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index 1585b8f2..7aefcfb5 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -929,12 +929,12 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con if(!(coverage > 0.0f)) { - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base*scales[0], + ComputePanGains(&Device->Dry, coeffs, DryGain.Base*scales[0], voice->mChans[0].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base*scales[0], + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base*scales[0], voice->mChans[0].mWetParams[i].Gains.Target); } } @@ -1038,13 +1038,13 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(size_t x{0};x < MaxAmbiChannels;++x) coeffs[x] += mixmatrix[acn][x] * scale; - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base, + ComputePanGains(&Device->Dry, coeffs, DryGain.Base, voice->mChans[c].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } @@ -1097,7 +1097,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } } @@ -1125,7 +1125,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[0].mWetParams[i].Gains.Target); } } @@ -1166,7 +1166,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } } @@ -1206,7 +1206,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } } @@ -1247,12 +1247,12 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con }; const auto coeffs = calc_coeffs(Device->mRenderMode); - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base, + ComputePanGains(&Device->Dry, coeffs, DryGain.Base, voice->mChans[0].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[0].mWetParams[i].Gains.Target); } } @@ -1296,12 +1296,12 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con pos = ScaleAzimuthFront3(pos); const auto coeffs = CalcDirectionCoeffs(pos, 0.0f); - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base, + ComputePanGains(&Device->Dry, coeffs, DryGain.Base, voice->mChans[c].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } } @@ -1343,12 +1343,12 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con const auto coeffs = CalcDirectionCoeffs((Device->mRenderMode==RenderMode::Pairwise) ? ScaleAzimuthFront3(chans[c].pos) : chans[c].pos, spread); - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base, + ComputePanGains(&Device->Dry, coeffs, DryGain.Base, voice->mChans[c].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { if(const EffectSlot *Slot{SendSlots[i]}) - ComputePanGains(&Slot->Wet, coeffs.data(), WetGain[i].Base, + ComputePanGains(&Slot->Wet, coeffs, WetGain[i].Base, voice->mChans[c].mWetParams[i].Gains.Target); } } diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index c84531d4..9cbc922f 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -133,8 +133,8 @@ void ChorusState::update(const ContextBase *Context, const EffectSlot *Slot, auto &rcoeffs = (device->mRenderMode != RenderMode::Pairwise) ? rcoeffs_nrml : rcoeffs_pw; mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, lcoeffs.data(), Slot->Gain, mGains[0].Target); - ComputePanGains(target.Main, rcoeffs.data(), Slot->Gain, mGains[1].Target); + ComputePanGains(target.Main, lcoeffs, Slot->Gain, mGains[0].Target); + ComputePanGains(target.Main, rcoeffs, Slot->Gain, mGains[1].Target); float rate{props->Chorus.Rate}; if(!(rate > 0.0f)) diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 06c34a37..5d1a6500 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -547,7 +547,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot for(size_t x{0};x < 4;++x) coeffs[x] = mixmatrix[acn][x] * scale; - ComputePanGains(target.Main, coeffs.data(), gain, (*mChans)[c].Target); + ComputePanGains(target.Main, coeffs, gain, (*mChans)[c].Target); } } else @@ -616,14 +616,14 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot { if(chanmap[i].channel == LFE) continue; const auto coeffs = CalcDirectionCoeffs(ScaleAzimuthFront(chanmap[i].pos), 0.0f); - ComputePanGains(target.Main, coeffs.data(), gain, (*mChans)[i].Target); + ComputePanGains(target.Main, coeffs, gain, (*mChans)[i].Target); } } else for(size_t i{0};i < chanmap.size();++i) { if(chanmap[i].channel == LFE) continue; const auto coeffs = CalcDirectionCoeffs(chanmap[i].pos, 0.0f); - ComputePanGains(target.Main, coeffs.data(), gain, (*mChans)[i].Target); + ComputePanGains(target.Main, coeffs, gain, (*mChans)[i].Target); } } } diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index e82b13d9..9ac68bec 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -97,7 +97,7 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot, static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f}); mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, coeffs.data(), Gain, mTargetGains); + ComputePanGains(target.Main, coeffs, Gain, mTargetGains); } } } diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index 392d81c8..3d77ff35 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -98,7 +98,7 @@ void DistortionState::update(const ContextBase *context, const EffectSlot *slot, static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f}); mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, coeffs.data(), slot->Gain*props->Distortion.Gain, mGain); + ComputePanGains(target.Main, coeffs, slot->Gain*props->Distortion.Gain, mGain); } void DistortionState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index 7824c246..714649c9 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -118,8 +118,8 @@ void EchoState::update(const ContextBase *context, const EffectSlot *slot, const auto coeffs1 = CalcAngleCoeffs( angle, 0.0f, 0.0f); mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, coeffs0.data(), slot->Gain, mGains[0].Target); - ComputePanGains(target.Main, coeffs1.data(), slot->Gain, mGains[1].Target); + ComputePanGains(target.Main, coeffs0, slot->Gain, mGains[0].Target); + ComputePanGains(target.Main, coeffs1, slot->Gain, mGains[1].Target); } void EchoState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index ec0cc29f..d3989e84 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -172,8 +172,8 @@ void FshifterState::update(const ContextBase *context, const EffectSlot *slot, auto &rcoeffs = (device->mRenderMode != RenderMode::Pairwise) ? rcoeffs_nrml : rcoeffs_pw; mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, lcoeffs.data(), slot->Gain, mGains[0].Target); - ComputePanGains(target.Main, rcoeffs.data(), slot->Gain, mGains[1].Target); + ComputePanGains(target.Main, lcoeffs, slot->Gain, mGains[0].Target); + ComputePanGains(target.Main, rcoeffs, slot->Gain, mGains[1].Target); } void FshifterState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index 2460cf78..95269009 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -145,7 +145,7 @@ void PshifterState::update(const ContextBase*, const EffectSlot *slot, static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f}); mOutTarget = target.Main->Buffer; - ComputePanGains(target.Main, coeffs.data(), slot->Gain, mTargetGains); + ComputePanGains(target.Main, coeffs, slot->Gain, mTargetGains); } void PshifterState::process(const size_t samplesToDo, diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index b00f638b..9727f400 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -1108,9 +1108,9 @@ void ReverbPipeline::update3DPanning(const al::span<const float,3> ReflectionsPa auto latecoeffs = mult_matrix(latemat); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(mainMix, earlycoeffs[i].data(), earlyGain, mEarly.TargetGains[i]); + ComputePanGains(mainMix, earlycoeffs[i], earlyGain, mEarly.TargetGains[i]); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(mainMix, latecoeffs[i].data(), lateGain, mLate.TargetGains[i]); + ComputePanGains(mainMix, latecoeffs[i], lateGain, mLate.TargetGains[i]); } else { @@ -1140,9 +1140,9 @@ void ReverbPipeline::update3DPanning(const al::span<const float,3> ReflectionsPa auto latecoeffs = mult_matrix(LateA2B, latemat); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(mainMix, earlycoeffs[i].data(), earlyGain, mEarly.TargetGains[i]); + ComputePanGains(mainMix, earlycoeffs[i], earlyGain, mEarly.TargetGains[i]); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(mainMix, latecoeffs[i].data(), lateGain, mLate.TargetGains[i]); + ComputePanGains(mainMix, latecoeffs[i], lateGain, mLate.TargetGains[i]); } } diff --git a/core/mixer.cpp b/core/mixer.cpp index 066c57bd..806ac8b8 100644 --- a/core/mixer.cpp +++ b/core/mixer.cpp @@ -82,14 +82,13 @@ std::array<float,MaxAmbiChannels> CalcAmbiCoeffs(const float y, const float z, c return coeffs; } -void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const float ingain, - const al::span<float,MaxAmbiChannels> gains) +void ComputePanGains(const MixParams *mix, const al::span<const float,MaxAmbiChannels> coeffs, + const float ingain, const al::span<float,MaxAmbiChannels> gains) { auto ambimap = mix->AmbiMap.cbegin(); auto iter = std::transform(ambimap, ambimap+mix->Buffer.size(), gains.begin(), [coeffs,ingain](const BFChannelConfig &chanmap) noexcept -> float - { return chanmap.Scale * coeffs[chanmap.Index] * ingain; } - ); + { return chanmap.Scale * coeffs[chanmap.Index] * ingain; }); std::fill(iter, gains.end(), 0.0f); } diff --git a/core/mixer.h b/core/mixer.h index a9c1f931..9062ebac 100644 --- a/core/mixer.h +++ b/core/mixer.h @@ -103,7 +103,7 @@ inline std::array<float,MaxAmbiChannels> CalcAngleCoeffs(const float azimuth, * coeffs are a 'slice' of a transform matrix for the input channel, used to * scale and orient the sound samples. */ -void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const float ingain, - const al::span<float,MaxAmbiChannels> gains); +void ComputePanGains(const MixParams *mix, const al::span<const float,MaxAmbiChannels> coeffs, + const float ingain, const al::span<float,MaxAmbiChannels> gains); #endif /* CORE_MIXER_H */ |