From a89345540520cb4fca40fc394eeac4b5f071680d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 10 Sep 2023 22:50:02 -0700 Subject: Combine multiple divisions into one --- alc/effects/reverb.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'alc/effects/reverb.cpp') diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index a4155792..429d0225 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -461,8 +461,9 @@ struct ReverbPipeline { void updateDelayLine(const float earlyDelay, const float lateDelay, const float density_mult, const float decayTime, const float frequency); - void update3DPanning(const float *ReflectionsPan, const float *LateReverbPan, - const float earlyGain, const float lateGain, const bool doUpmix, const MixParams *mainMix); + void update3DPanning(const al::span ReflectionsPan, + const al::span LateReverbPan, const float earlyGain, const float lateGain, + const bool doUpmix, const MixParams *mainMix); void processEarly(size_t offset, const size_t samplesToDo, const al::span tempSamples, @@ -1028,7 +1029,7 @@ void ReverbPipeline::updateDelayLine(const float earlyDelay, const float lateDel * focal strength. This function results in a B-Format transformation matrix * that spatially focuses the signal in the desired direction. */ -std::array,4> GetTransformFromVector(const float *vec) +std::array,4> GetTransformFromVector(const al::span vec) { /* Normalize the panning vector according to the N3D scale, which has an * extra sqrt(3) term on the directional components. Converting from OpenAL @@ -1041,9 +1042,10 @@ std::array,4> GetTransformFromVector(const float *vec) float mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])}; if(mag > 1.0f) { - norm[0] = vec[0] / mag * -al::numbers::sqrt3_v; - norm[1] = vec[1] / mag * al::numbers::sqrt3_v; - norm[2] = vec[2] / mag * al::numbers::sqrt3_v; + const float scale{al::numbers::sqrt3_v / mag}; + norm[0] = vec[0] * -scale; + norm[1] = vec[1] * scale; + norm[2] = vec[2] * scale; mag = 1.0f; } else @@ -1066,8 +1068,9 @@ std::array,4> GetTransformFromVector(const float *vec) } /* Update the early and late 3D panning gains. */ -void ReverbPipeline::update3DPanning(const float *ReflectionsPan, const float *LateReverbPan, - const float earlyGain, const float lateGain, const bool doUpmix, const MixParams *mainMix) +void ReverbPipeline::update3DPanning(const al::span ReflectionsPan, + const al::span LateReverbPan, const float earlyGain, const float lateGain, + const bool doUpmix, const MixParams *mainMix) { /* Create matrices that transform a B-Format signal according to the * panning vectors. -- cgit v1.2.3