diff options
author | Chris Robinson <[email protected]> | 2018-02-17 21:15:39 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-02-18 23:56:51 -0800 |
commit | fa9ab9af7cb559ff9ecc1846f2996265bfbea1ec (patch) | |
tree | a2979592ba166a6667a90e1ab61e9f2811b10d9c /Alc/hrtf.c | |
parent | b5aa0c07599ce8e8fd17e4ec1a686f3cf0576458 (diff) |
Minimize each response delay for the ambisonic HRTF decode
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r-- | Alc/hrtf.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -204,6 +204,7 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N BandSplitter splitter; ALsizei idx[HRTF_AMBI_MAX_CHANNELS]; ALsizei min_delay = HRTF_HISTORY_LENGTH; + ALsizei max_delay = 0; ALfloat temps[3][HRIR_LENGTH]; ALsizei max_length = 0; ALsizei i, c, b; @@ -228,8 +229,6 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N /* Calculate indices for left and right channels. */ idx[c] = evoffset + azidx; - - min_delay = mini(min_delay, mini(Hrtf->delays[idx[c]][0], Hrtf->delays[idx[c]][1])); } memset(temps, 0, sizeof(temps)); @@ -237,8 +236,12 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N for(c = 0;c < AmbiCount;c++) { const ALfloat (*fir)[2] = &Hrtf->coeffs[idx[c] * Hrtf->irSize]; - ALsizei ldelay = Hrtf->delays[idx[c]][0] - min_delay; - ALsizei rdelay = Hrtf->delays[idx[c]][1] - min_delay; + const ALsizei res_delay = mini(Hrtf->delays[idx[c]][0], Hrtf->delays[idx[c]][1]); + ALsizei ldelay = Hrtf->delays[idx[c]][0] - res_delay; + ALsizei rdelay = Hrtf->delays[idx[c]][1] - res_delay; + + min_delay = mini(min_delay, res_delay); + max_delay = maxi(max_delay, res_delay); max_length = maxi(max_length, mini(maxi(ldelay, rdelay) + Hrtf->irSize, HRIR_LENGTH) @@ -308,7 +311,8 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N max_length += MOD_IR_SIZE-1; max_length -= max_length%MOD_IR_SIZE; - TRACE("Skipped min delay: %d, new combined length: %d\n", min_delay, max_length); + TRACE("Skipped delay min: %d, max: %d, new FIR length: %d\n", min_delay, max_delay, + max_length); state->IrSize = max_length; #undef NUM_BANDS } |