diff options
author | Chris Robinson <[email protected]> | 2019-05-29 11:13:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-05-29 11:13:35 -0700 |
commit | d0f0a5fdca87f74ef46ad26cb79975e1c6cda8f0 (patch) | |
tree | b1a42cf22c86961060e7aac12fd1badff6049829 | |
parent | ec3a6f8cded70aeb54e9c658fa68a680c017e1ef (diff) |
Separate two HRTF passes into two loops
-rw-r--r-- | Alc/mixer/hrtfbase.h | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/Alc/mixer/hrtfbase.h b/Alc/mixer/hrtfbase.h index 8549f6ba..571cdc89 100644 --- a/Alc/mixer/hrtfbase.h +++ b/Alc/mixer/hrtfbase.h @@ -23,13 +23,12 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const auto &Coeffs = *hrtfparams->Coeffs; const ALfloat gainstep{hrtfparams->GainStep}; const ALfloat gain{hrtfparams->Gain}; - ALfloat stepcount{0.0f}; ALsizei Delay[2]{ HRTF_HISTORY_LENGTH - hrtfparams->Delay[0], HRTF_HISTORY_LENGTH - hrtfparams->Delay[1] }; ASSUME(Delay[0] >= 0 && Delay[1] >= 0); - + ALfloat stepcount{0.0f}; for(ALsizei i{0};i < BufferSize;++i) { const ALfloat g{gain + gainstep*stepcount}; @@ -39,6 +38,7 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, stepcount += 1.0f; } + for(ALsizei i{0};i < BufferSize;++i) LeftOut[OutPos+i] += AccumSamples[i][0]; for(ALsizei i{0};i < BufferSize;++i) @@ -58,35 +58,40 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut const ALfloat oldGainStep{-oldGain / static_cast<ALfloat>(BufferSize)}; const auto &NewCoeffs = *newparams->Coeffs; const ALfloat newGainStep{newparams->GainStep}; - ALfloat stepcount{0.0f}; ASSUME(OutPos >= 0); ASSUME(IrSize >= 4); ASSUME(BufferSize > 0); - ALsizei OldDelay[2]{ + ALsizei Delay[2]{ HRTF_HISTORY_LENGTH - oldparams->Delay[0], HRTF_HISTORY_LENGTH - oldparams->Delay[1] }; - ASSUME(OldDelay[0] >= 0 && OldDelay[1] >= 0); - ALsizei NewDelay[2]{ - HRTF_HISTORY_LENGTH - newparams->Delay[0], - HRTF_HISTORY_LENGTH - newparams->Delay[1] }; - ASSUME(NewDelay[0] >= 0 && NewDelay[1] >= 0); - + ASSUME(Delay[0] >= 0 && Delay[1] >= 0); + ALfloat stepcount{0.0f}; for(ALsizei i{0};i < BufferSize;++i) { - ALfloat g{oldGain + oldGainStep*stepcount}; - ALfloat left{InSamples[OldDelay[0]++] * g}; - ALfloat right{InSamples[OldDelay[1]++] * g}; + const ALfloat g{oldGain + oldGainStep*stepcount}; + const ALfloat left{InSamples[Delay[0]++] * g}; + const ALfloat right{InSamples[Delay[1]++] * g}; ApplyCoeffs(i, AccumSamples+i, IrSize, OldCoeffs, left, right); - g = newGainStep*stepcount; - left = InSamples[NewDelay[0]++] * g; - right = InSamples[NewDelay[1]++] * g; + stepcount += 1.0f; + } + + Delay[0] = HRTF_HISTORY_LENGTH - newparams->Delay[0]; + Delay[1] = HRTF_HISTORY_LENGTH - newparams->Delay[1]; + ASSUME(Delay[0] >= 0 && Delay[1] >= 0); + stepcount = 0.0f; + for(ALsizei i{0};i < BufferSize;++i) + { + const ALfloat g{newGainStep*stepcount}; + const ALfloat left{InSamples[Delay[0]++] * g}; + const ALfloat right{InSamples[Delay[1]++] * g}; ApplyCoeffs(i, AccumSamples+i, IrSize, NewCoeffs, left, right); stepcount += 1.0f; } + for(ALsizei i{0};i < BufferSize;++i) LeftOut[OutPos+i] += AccumSamples[i][0]; for(ALsizei i{0};i < BufferSize;++i) |