diff options
author | Chris Robinson <[email protected]> | 2016-11-01 02:20:19 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-11-01 02:20:19 -0700 |
commit | 43e7323adba756ca96abef2e69a09461c8e1e633 (patch) | |
tree | 74f992a6853d6d9ba70cb8a16bd55dbda1c7223e /Alc/hrtf.c | |
parent | a44f4c2fcb3cb22737a46b8a2419ff7bd1ce3555 (diff) |
Rebalance the frequencies for B-Format HRTF coefficients
The original pseudo-inverse method that generated the LF matrix expects the
high frequencies to be scaled up by ~2.645751 over the low frequencies (or
sqrt(7), ~8.45dB). However, the AllRAD method used to generate the HF matrix
produced a matrix that was only scaled up by 1.46551981258 (based on the
average of the W coefficients).
Previously, the LF matrix was scaled down by sqrt(7), as the difference
specified in the pseudo-inverse results. This failed to account for the
increase already present in the HF matrix, so now the LF matrix is scaled down
by the remaining difference between the expected scaling and the scaling
already present in the HF matrix (sqrt(7) / 1.46551981258 = 1.80533302205, or
roughly 5.13dB, where the reciprocal is 0.553914423 for -5.13 dB).
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r-- | Alc/hrtf.c | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -158,21 +158,24 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ { DEG2RAD(-90.0f), DEG2RAD( 0.0f) }, }; static const ALfloat Ambi3DMatrix[14][2][MAX_AMBI_COEFFS] = { - { { 0.078851598f, 0.000000000f, 0.070561967f, 0.000000000f }, { 0.0269973975f, 0.0000000000f, 0.0467610443f, 0.0000000000f } }, - { { 0.124051278f, 0.059847972f, 0.059847972f, 0.059847972f }, { 0.0269973975f, 0.0269973975f, 0.0269973975f, 0.0269973975f } }, - { { 0.124051278f, -0.059847972f, 0.059847972f, 0.059847972f }, { 0.0269973975f, -0.0269973975f, 0.0269973975f, 0.0269973975f } }, - { { 0.124051278f, -0.059847972f, 0.059847972f, -0.059847972f }, { 0.0269973975f, -0.0269973975f, 0.0269973975f, -0.0269973975f } }, - { { 0.124051278f, 0.059847972f, 0.059847972f, -0.059847972f }, { 0.0269973975f, 0.0269973975f, 0.0269973975f, -0.0269973975f } }, - { { 0.078851598f, 0.000000000f, 0.000000000f, 0.070561967f }, { 0.0269973975f, 0.0000000000f, 0.0000000000f, 0.0467610443f } }, - { { 0.078851598f, -0.070561967f, 0.000000000f, 0.000000000f }, { 0.0269973975f, -0.0467610443f, 0.0000000000f, 0.0000000000f } }, - { { 0.078851598f, 0.000000000f, 0.000000000f, -0.070561967f }, { 0.0269973975f, 0.0000000000f, 0.0000000000f, -0.0467610443f } }, - { { 0.078851598f, 0.070561967f, 0.000000000f, 0.000000000f }, { 0.0269973975f, 0.0467610443f, 0.0000000000f, 0.0000000000f } }, - { { 0.124051278f, 0.059847972f, -0.059847972f, 0.059847972f }, { 0.0269973975f, 0.0269973975f, -0.0269973975f, 0.0269973975f } }, - { { 0.124051278f, -0.059847972f, -0.059847972f, 0.059847972f }, { 0.0269973975f, -0.0269973975f, -0.0269973975f, 0.0269973975f } }, - { { 0.124051278f, -0.059847972f, -0.059847972f, -0.059847972f }, { 0.0269973975f, -0.0269973975f, -0.0269973975f, -0.0269973975f } }, - { { 0.124051278f, 0.059847972f, -0.059847972f, -0.059847972f }, { 0.0269973975f, 0.0269973975f, -0.0269973975f, -0.0269973975f } }, - { { 0.078851598f, 0.000000000f, -0.070561967f, 0.000000000f }, { 0.0269973975f, 0.0000000000f, -0.0467610443f, 0.0000000000f } }, + { { 0.078851598f, 0.000000000f, 0.070561967f, 0.000000000f }, { 0.0714285714f, 0.0000000000f, 0.1237180798f, 0.0000000000f } }, + { { 0.124051278f, 0.059847972f, 0.059847972f, 0.059847972f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, 0.0714285714f } }, + { { 0.124051278f, -0.059847972f, 0.059847972f, 0.059847972f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, 0.0714285714f } }, + { { 0.124051278f, -0.059847972f, 0.059847972f, -0.059847972f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, -0.0714285714f } }, + { { 0.124051278f, 0.059847972f, 0.059847972f, -0.059847972f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, -0.0714285714f } }, + { { 0.078851598f, 0.000000000f, 0.000000000f, 0.070561967f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, 0.1237180798f } }, + { { 0.078851598f, -0.070561967f, 0.000000000f, 0.000000000f }, { 0.0714285714f, -0.1237180798f, 0.0000000000f, 0.0000000000f } }, + { { 0.078851598f, 0.000000000f, 0.000000000f, -0.070561967f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, -0.1237180798f } }, + { { 0.078851598f, 0.070561967f, 0.000000000f, 0.000000000f }, { 0.0714285714f, 0.1237180798f, 0.0000000000f, 0.0000000000f } }, + { { 0.124051278f, 0.059847972f, -0.059847972f, 0.059847972f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, 0.0714285714f } }, + { { 0.124051278f, -0.059847972f, -0.059847972f, 0.059847972f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, 0.0714285714f } }, + { { 0.124051278f, -0.059847972f, -0.059847972f, -0.059847972f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, -0.0714285714f } }, + { { 0.124051278f, 0.059847972f, -0.059847972f, -0.059847972f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, -0.0714285714f } }, + { { 0.078851598f, 0.000000000f, -0.070561967f, 0.000000000f }, { 0.0714285714f, 0.0000000000f, -0.1237180798f, 0.0000000000f } }, }; +#define AMBIHF_GAIN 1.0f +#define AMBILF_GAIN 0.553914423f /* -5.13dB */ + /* Change this to 2 for dual-band HRTF processing. May require a higher quality * band-splitter, or better calculation of the new IR length to deal with the * tail generated by the filter. @@ -233,6 +236,11 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ for(i = 0;i < Hrtf->irSize;i++) temps[2][i] = fir[i] / 32767.0f; bandsplit_process(&splitter, temps[0], temps[1], temps[2], HRIR_LENGTH); + /* Scale the low and high frequency responses. */ + for(i = 0;i < HRIR_LENGTH;i++) + temps[0][i] *= AMBIHF_GAIN; + for(i = 0;i < HRIR_LENGTH;i++) + temps[1][i] *= AMBILF_GAIN; } /* Add to the left output coefficients with the specified delay. */ @@ -262,6 +270,11 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ for(i = 0;i < Hrtf->irSize;i++) temps[2][i] = fir[i] / 32767.0f; bandsplit_process(&splitter, temps[0], temps[1], temps[2], HRIR_LENGTH); + /* Scale the low and high frequency responses. */ + for(i = 0;i < HRIR_LENGTH;i++) + temps[0][i] *= AMBIHF_GAIN; + for(i = 0;i < HRIR_LENGTH;i++) + temps[1][i] *= AMBILF_GAIN; } /* Add to the right output coefficients with the specified delay. */ |