aboutsummaryrefslogtreecommitdiffstats
path: root/alc/panning.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-05 20:00:22 -0700
committerChris Robinson <[email protected]>2019-10-05 20:00:22 -0700
commiteb89faf9632048568c953c21a6b58e4c4664cc05 (patch)
treeb4e3de1b1535c81ba9be75ce0558e35b5c9a88a0 /alc/panning.cpp
parent267b79f337f2189542ce2582aeed84b84c6e987e (diff)
Use a span instead of a reference-to-array
Diffstat (limited to 'alc/panning.cpp')
-rw-r--r--alc/panning.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp
index c2bcf223..df0b870a 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -874,8 +874,8 @@ void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device)
}
-void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALfloat spread,
- ALfloat (&coeffs)[MAX_AMBI_CHANNELS])
+void CalcAmbiCoeffs(const float y, const float z, const float x, const float spread,
+ const al::span<float,MAX_AMBI_CHANNELS> coeffs)
{
/* Zeroth-order */
coeffs[0] = 1.0f; /* ACN 0 = 1 */
@@ -934,14 +934,14 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf
* ZH4 = 0.125f * (ca+1.0f)*(7.0f*ca*ca - 3.0f)*ca;
* ZH5 = 0.0625f * (ca+1.0f)*(21.0f*ca*ca*ca*ca - 14.0f*ca*ca + 1.0f);
*/
- ALfloat ca = std::cos(spread * 0.5f);
+ const float ca{std::cos(spread * 0.5f)};
/* Increase the source volume by up to +3dB for a full spread. */
- ALfloat scale = std::sqrt(1.0f + spread/al::MathDefs<float>::Tau());
+ const float scale{std::sqrt(1.0f + spread/al::MathDefs<float>::Tau())};
- ALfloat ZH0_norm = scale;
- ALfloat ZH1_norm = 0.5f * (ca+1.f) * scale;
- ALfloat ZH2_norm = 0.5f * (ca+1.f)*ca * scale;
- ALfloat ZH3_norm = 0.125f * (ca+1.f)*(5.f*ca*ca-1.f) * scale;
+ const float ZH0_norm{scale};
+ const float ZH1_norm{scale * 0.5f * (ca+1.f)};
+ const float ZH2_norm{scale * 0.5f * (ca+1.f)*ca};
+ const float ZH3_norm{scale * 0.125f * (ca+1.f)*(5.f*ca*ca-1.f)};
/* Zeroth-order */
coeffs[0] *= ZH0_norm;
@@ -966,13 +966,14 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf
}
}
-void ComputePanGains(const MixParams *mix, const ALfloat *RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
+void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const float ingain,
+ const al::span<float,MAX_OUTPUT_CHANNELS> gains)
{
auto ambimap = mix->AmbiMap.cbegin();
- auto iter = std::transform(ambimap, ambimap+mix->Buffer.size(), std::begin(gains),
- [coeffs,ingain](const BFChannelConfig &chanmap) noexcept -> ALfloat
+ 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; }
);
- std::fill(iter, std::end(gains), 0.0f);
+ std::fill(iter, gains.end(), 0.0f);
}