aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-08-30 22:33:33 -0700
committerChris Robinson <[email protected]>2016-08-30 22:33:33 -0700
commitf791b8c517732adf3dfc50b5b6086400b720960b (patch)
tree0c16780316910ec8691ac2baa7e410c94ea5a90f /Alc/hrtf.c
parent8d3a2865775e1747cb7f2905635bb95a43d5d0ee (diff)
Add a compile-time macro to use dual-band ambisonic HRTF processing
Use single-band processing for now, to see if dual-band is causing a drop in quality at all.
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r--Alc/hrtf.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index b11fb9a8..d0511083 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -198,6 +198,11 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][
{ { 0.25f, 0.14425f, -0.14425f, -0.14425f }, { 0.125f, 0.125f, -0.125f, -0.125f } },
{ { 0.25f, -0.14425f, -0.14425f, -0.14425f }, { 0.125f, -0.125f, -0.125f, -0.125f } },
};
+/* 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.
+ */
+#define NUM_BANDS 1
BandSplitter splitter;
ALfloat temps[3][HRIR_LENGTH];
ALuint lidx[8], ridx[8];
@@ -239,18 +244,27 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][
const ALshort *fir;
ALuint delay;
- /* Band-split left HRIR into low and high frequency responses. */
- bandsplit_clear(&splitter);
+ /* Convert the left FIR from shorts to float */
fir = &Hrtf->coeffs[lidx[c] * Hrtf->irSize];
- 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);
+ if(NUM_BANDS == 1)
+ {
+ for(i = 0;i < Hrtf->irSize;i++)
+ temps[0][i] = fir[i] / 32767.0f;
+ }
+ else
+ {
+ /* Band-split left HRIR into low and high frequency responses. */
+ bandsplit_clear(&splitter);
+ 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);
+ }
/* Add to the left output coefficients with the specified delay. */
delay = Hrtf->delays[lidx[c]] - min_delay;
for(i = 0;i < NumChannels;++i)
{
- for(b = 0;b < 2;b++)
+ for(b = 0;b < NUM_BANDS;b++)
{
ALuint k = 0;
for(j = delay;j < HRIR_LENGTH;++j)
@@ -259,18 +273,27 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][
}
max_length = maxu(max_length, minu(delay + Hrtf->irSize, HRIR_LENGTH));
- /* Band-split right HRIR into low and high frequency responses. */
- bandsplit_clear(&splitter);
+ /* Convert the right FIR from shorts to float */
fir = &Hrtf->coeffs[ridx[c] * Hrtf->irSize];
- 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);
+ if(NUM_BANDS == 1)
+ {
+ for(i = 0;i < Hrtf->irSize;i++)
+ temps[0][i] = fir[i] / 32767.0f;
+ }
+ else
+ {
+ /* Band-split right HRIR into low and high frequency responses. */
+ bandsplit_clear(&splitter);
+ 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);
+ }
/* Add to the right output coefficients with the specified delay. */
delay = Hrtf->delays[ridx[c]] - min_delay;
for(i = 0;i < NumChannels;++i)
{
- for(b = 0;b < 2;b++)
+ for(b = 0;b < NUM_BANDS;b++)
{
ALuint k = 0;
for(j = delay;j < HRIR_LENGTH;++j)
@@ -280,6 +303,7 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][
max_length = maxu(max_length, minu(delay + Hrtf->irSize, HRIR_LENGTH));
}
TRACE("Skipped min delay: %u, new combined length: %u\n", min_delay, max_length);
+#undef NUM_BANDS
return max_length;
}