aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/panning.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-07-18 22:15:32 -0700
committerChris Robinson <[email protected]>2017-07-18 22:15:32 -0700
commit0135ddc2e5857e172fccd6ec635275eeae4ae869 (patch)
treecbb7991ab4f7f7c4af6ce0f0d96652baf7ec415e /Alc/panning.c
parent5f7268c0cc356b08db0d25ca3e665078180d0aec (diff)
Scale the source volume by +3dB for a full spread
This effectively turns a full spread source into an ambient response, preventing such sources from being unexpectedly quiet.
Diffstat (limited to 'Alc/panning.c')
-rw-r--r--Alc/panning.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Alc/panning.c b/Alc/panning.c
index a5cddcb2..0abf18db 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -152,8 +152,7 @@ void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MA
* ZH5 = -0.0625*sqrt(pi) * (-1+ca)*(ca+1)*(21*ca*ca*ca*ca - 14*ca*ca + 1);
*
* The gain of the source is compensated for size, so that the
- * loundness doesn't depend on the spread. That is, the factors are
- * scaled so that ZH0 remains 1 regardless of the spread. Thus:
+ * loundness doesn't depend on the spread. Thus:
*
* ZH0 = 1.0f;
* ZH1 = 0.5f * (ca+1.0f);
@@ -163,11 +162,13 @@ void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MA
* ZH5 = 0.0625f * (ca+1.0f)*(21.0f*ca*ca*ca*ca - 14.0f*ca*ca + 1.0f);
*/
ALfloat ca = cosf(spread * 0.5f);
+ /* Increase the source volume by up to +3dB for a full spread. */
+ ALfloat scale = sqrtf(1.0f + spread/F_TAU);
- ALfloat ZH0_norm = 1.0f;
- ALfloat ZH1_norm = 0.5f * (ca+1.f);
- ALfloat ZH2_norm = 0.5f * (ca+1.f)*ca;
- ALfloat ZH3_norm = 0.125f * (ca+1.f)*(5.f*ca*ca-1.f);
+ 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;
/* Zeroth-order */
coeffs[0] *= ZH0_norm;