aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-07-17 18:02:23 -0700
committerChris Robinson <[email protected]>2014-07-17 18:02:23 -0700
commit23cae7783da9cb18096ba0c02177d6f5ca6a8663 (patch)
treeea07b6515473b458f599fed58ff3cb078a4be353 /Alc
parent8635733d59943f6863745862f8425db6c0445d82 (diff)
Properly scale the first HRTF pass-through coefficient
Coefficients are scaled by 32767. For pass-through, this is attenuated by sqrt(0.5) to maintain a consistent perceived volume.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/hrtf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 08490e97..707655a0 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -58,6 +58,10 @@ struct Hrtf {
static const ALchar magicMarker00[8] = "MinPHR00";
static const ALchar magicMarker01[8] = "MinPHR01";
+/* First value for pass-through coefficients (remaining are 0), used for omni-
+ * directional sounds. */
+static const ALfloat PassthruCoeff = 32767.0f * 0.707106781187f/*sqrt(0.5)*/;
+
static struct Hrtf *LoadedHrtfs = NULL;
/* Calculate the elevation indices given the polar elevation in radians.
@@ -184,10 +188,10 @@ void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azi
i = 0;
c = (Hrtf->coeffs[lidx[0]+i]*blend[0] + Hrtf->coeffs[lidx[1]+i]*blend[1] +
Hrtf->coeffs[lidx[2]+i]*blend[2] + Hrtf->coeffs[lidx[3]+i]*blend[3]);
- coeffs[i][0] = lerp(1.0f, c, dirfact) * gain;
+ coeffs[i][0] = lerp(PassthruCoeff, c, dirfact) * gain;
c = (Hrtf->coeffs[ridx[0]+i]*blend[0] + Hrtf->coeffs[ridx[1]+i]*blend[1] +
Hrtf->coeffs[ridx[2]+i]*blend[2] + Hrtf->coeffs[ridx[3]+i]*blend[3]);
- coeffs[i][1] = lerp(1.0f, c, dirfact) * gain;
+ coeffs[i][1] = lerp(PassthruCoeff, c, dirfact) * gain;
for(i = 1;i < Hrtf->irSize;i++)
{
@@ -298,10 +302,10 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
c = (Hrtf->coeffs[lidx[0]+i]*blend[0] + Hrtf->coeffs[lidx[1]+i]*blend[1] +
Hrtf->coeffs[lidx[2]+i]*blend[2] + Hrtf->coeffs[lidx[3]+i]*blend[3]);
- coeffs[i][0] = lerp(1.0f, c, dirfact) * gain;
+ coeffs[i][0] = lerp(PassthruCoeff, c, dirfact) * gain;
c = (Hrtf->coeffs[ridx[0]+i]*blend[0] + Hrtf->coeffs[ridx[1]+i]*blend[1] +
Hrtf->coeffs[ridx[2]+i]*blend[2] + Hrtf->coeffs[ridx[3]+i]*blend[3]);
- coeffs[i][1] = lerp(1.0f, c, dirfact) * gain;
+ coeffs[i][1] = lerp(PassthruCoeff, c, dirfact) * gain;
coeffStep[i][0] = step * (coeffs[i][0] - left);
coeffStep[i][1] = step * (coeffs[i][1] - right);