aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-02-20 00:53:01 -0800
committerChris Robinson <[email protected]>2016-02-20 00:53:01 -0800
commite1ce7f9180d8127397faebf36eb815a5a575d7c8 (patch)
treede56927ad814a6a41a893cdc5332332bc27aeaf0 /Alc/hrtf.c
parente90cdbcf98662a86326b5b3f84f3b46534d7766e (diff)
Use an 8-channel cube for HRTF's virtual format.
There were phase issues caused by applying HRTF directly to the B-Format channels, since the HRIR delays were all averaged which removed the inter-aural time-delay, which in turn removed significant spatial information.
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r--Alc/hrtf.c102
1 files changed, 0 insertions, 102 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index c4cacf87..e4052f52 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -181,108 +181,6 @@ void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azi
}
}
-/* Calculates HRTF coefficients for B-Format channels (only up to first-order).
- * Note that these will decode a B-Format output mix, which uses FuMa ordering
- * and scaling, not N3D!
- */
-void GetBFormatHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat (*coeffs_list[4])[2], ALuint *delay_list[4])
-{
- ALuint elev_idx, azi_idx;
- ALfloat scale;
- ALuint i, c;
-
- for(c = 0;c < 4;c++)
- {
- ALfloat (*coeffs)[2] = coeffs_list[c];
- ALuint *delay = delay_list[c];
-
- for(i = 0;i < Hrtf->irSize;i++)
- {
- coeffs[i][0] = 0.0f;
- coeffs[i][1] = 0.0f;
- }
- delay[0] = 0;
- delay[1] = 0;
- }
-
- /* NOTE: HRTF coefficients are generated by combining all the HRIRs in the
- * dataset, with each entry scaled according to how much it contributes to
- * the given B-Format channel based on its direction (including negative
- * contributions!).
- */
- scale = 0.0f;
- for(elev_idx = 0;elev_idx < Hrtf->evCount;elev_idx++)
- {
- ALfloat elev = (ALfloat)elev_idx/(ALfloat)(Hrtf->evCount-1)*F_PI - F_PI_2;
- ALuint evoffset = Hrtf->evOffset[elev_idx];
- ALuint azcount = Hrtf->azCount[elev_idx];
-
- scale += (ALfloat)azcount;
-
- for(azi_idx = 0;azi_idx < azcount;azi_idx++)
- {
- ALuint lidx, ridx;
- ALfloat ambi_coeffs[4];
- ALfloat az, gain;
- ALfloat x, y, z;
-
- lidx = evoffset + azi_idx;
- ridx = evoffset + ((azcount-azi_idx) % azcount);
-
- az = (ALfloat)azi_idx / (ALfloat)azcount * F_TAU;
- if(az > F_PI) az -= F_TAU;
-
- x = cosf(-az) * cosf(elev);
- y = sinf(-az) * cosf(elev);
- z = sinf(elev);
-
- ambi_coeffs[0] = 1.414213562f;
- ambi_coeffs[1] = x;
- ambi_coeffs[2] = y;
- ambi_coeffs[3] = z;
-
- for(c = 0;c < 4;c++)
- {
- ALfloat (*coeffs)[2] = coeffs_list[c];
- ALuint *delay = delay_list[c];
-
- /* NOTE: Always include the total delay average since the
- * channels need to have matching delays. */
- delay[0] += Hrtf->delays[lidx];
- delay[1] += Hrtf->delays[ridx];
-
- gain = ambi_coeffs[c];
- if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
- continue;
-
- for(i = 0;i < Hrtf->irSize;i++)
- {
- coeffs[i][0] += Hrtf->coeffs[lidx*Hrtf->irSize + i]*(1.0f/32767.0f) * gain;
- coeffs[i][1] += Hrtf->coeffs[ridx*Hrtf->irSize + i]*(1.0f/32767.0f) * gain;
- }
- }
- }
- }
-
- scale = 1.0f/scale;
-
- for(c = 0;c < 4;c++)
- {
- ALfloat (*coeffs)[2] = coeffs_list[c];
- ALuint *delay = delay_list[c];
-
- for(i = 0;i < Hrtf->irSize;i++)
- {
- coeffs[i][0] *= scale;
- coeffs[i][1] *= scale;
- }
- delay[0] = minu((ALuint)((ALfloat)delay[0] * scale), HRTF_HISTORY_LENGTH-1);
- delay[0] <<= HRTFDELAY_BITS;
- delay[1] = minu((ALuint)((ALfloat)delay[1] * scale), HRTF_HISTORY_LENGTH-1);
- delay[1] <<= HRTFDELAY_BITS;
- }
-}
-
static struct Hrtf *LoadHrtf00(FILE *f)
{