From 96aaab93662be289d3b2c5312ae50502afa8d221 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 11 Mar 2017 18:04:06 -0800 Subject: Rework HRTF coefficient fading This improves fading between HRIRs as sources pan around. In particular, it improves the issue with individual coefficients having various rounding errors in the stepping values, as well as issues with interpolating delay values. It does this by doing two mixing passes for each source. First using the last coefficients that fade to silence, and then again using the new coefficients that fade from silence. When added together, it creates a linear fade from one to the other. Additionally, the gain is applied separately so the individual coefficients don't step with rounding errors. Although this does increase CPU cost since it's doing two mixes per source, each mix is a bit cheaper now since the stepping is simplified to a single gain value, and the overall quality is improved. --- OpenAL32/Include/alu.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'OpenAL32/Include/alu.h') diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 8888bdc0..72f33be2 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -116,12 +116,9 @@ enum ActiveFilters { typedef struct MixHrtfParams { - const HrtfParams *Target; - HrtfParams *Current; - struct { - alignas(16) ALfloat Coeffs[HRIR_LENGTH][2]; - ALsizei Delay[2]; - } Steps; + const HrtfParams *Current; + ALfloat Gain; + ALfloat GainStep; } MixHrtfParams; @@ -133,7 +130,7 @@ typedef struct DirectParams { NfcFilter NFCtrlFilter[MAX_AMBI_ORDER]; struct { - HrtfParams Current; + HrtfParams Old; HrtfParams Target; HrtfState State; } Hrtf; @@ -225,13 +222,13 @@ typedef void (*RowMixerFunc)(ALfloat *OutBuffer, const ALfloat *gains, const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, ALsizei InPos, ALsizei BufferSize); typedef void (*HrtfMixerFunc)(ALfloat *restrict LeftOut, ALfloat *restrict RightOut, - const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos, - const ALsizei IrSize, const MixHrtfParams *hrtfparams, + const ALfloat *data, ALsizei Offset, ALsizei OutPos, + const ALsizei IrSize, MixHrtfParams *hrtfparams, HrtfState *hrtfstate, ALsizei BufferSize); typedef void (*HrtfDirectMixerFunc)(ALfloat *restrict LeftOut, ALfloat *restrict RightOut, const ALfloat *data, ALsizei Offset, const ALsizei IrSize, - ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2], - ALsizei BufferSize); + const ALfloat (*restrict Coeffs)[2], + ALfloat (*restrict Values)[2], ALsizei BufferSize); #define GAIN_MIX_MAX (16.0f) /* +24dB */ -- cgit v1.2.3