From a9e71c2668e7c49d089623633bd92bcfc3fe1465 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2018 23:33:04 -0800 Subject: Handle all input channels in MixDirectHrtf --- Alc/mixer/defs.h | 12 +++++------ Alc/mixer/hrtf_inc.cpp | 54 +++++++++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 31 deletions(-) (limited to 'Alc/mixer') diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h index 5bdf6e30..bac93d6f 100644 --- a/Alc/mixer/defs.h +++ b/Alc/mixer/defs.h @@ -31,8 +31,8 @@ void MixHrtfBlend_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, MixHrtfParams *newparams, HrtfState *hrtfstate, ALsizei BufferSize); void MixDirectHrtf_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, - const ALfloat *data, DirectHrtfState *State, const ALsizei Chan, - const ALsizei BufferSize); + const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, + const ALsizei NumChans, const ALsizei BufferSize); void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, ALsizei BufferSize); @@ -51,8 +51,8 @@ void MixHrtfBlend_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, MixHrtfParams *newparams, HrtfState *hrtfstate, ALsizei BufferSize); void MixDirectHrtf_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, - const ALfloat *data, DirectHrtfState *State, const ALsizei Chan, - const ALsizei BufferSize); + const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, + const ALsizei NumChans, const ALsizei BufferSize); void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, ALsizei BufferSize); @@ -97,8 +97,8 @@ void MixHrtfBlend_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, MixHrtfParams *newparams, HrtfState *hrtfstate, ALsizei BufferSize); void MixDirectHrtf_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, - const ALfloat *data, DirectHrtfState *State, const ALsizei Chan, - const ALsizei BufferSize); + const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, + const ALsizei NumChans, const ALsizei BufferSize); void Mix_Neon(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, ALsizei BufferSize); diff --git a/Alc/mixer/hrtf_inc.cpp b/Alc/mixer/hrtf_inc.cpp index caac7e54..6c0824dc 100644 --- a/Alc/mixer/hrtf_inc.cpp +++ b/Alc/mixer/hrtf_inc.cpp @@ -152,40 +152,44 @@ void MixHrtfBlend(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, } void MixDirectHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, - const ALfloat *data, DirectHrtfState *State, const ALsizei Chan, - const ALsizei BufferSize) + const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, + const ALsizei NumChans, const ALsizei BufferSize) { - ASSUME(Chan >= 0); + ASSUME(NumChans >= 0); ASSUME(BufferSize > 0); - const ALfloat (&Coeffs)[HRIR_LENGTH][2] = State->Chan[Chan].Coeffs; - ALfloat (&Values)[HRIR_LENGTH][2] = State->Chan[Chan].Values; - ALsizei Offset{State->Offset&HRIR_MASK}; const ALsizei IrSize{State->IrSize}; - ASSUME(IrSize >= 4); - ALsizei HeadOffset{(Offset+IrSize-1)&HRIR_MASK}; - for(ALsizei i{0};i < BufferSize;) + for(ALsizei c{0};c < NumChans;++c) { - const ALsizei todo_hrir{HRIR_LENGTH - maxi(HeadOffset, Offset)}; - const ALsizei todo{mini(BufferSize-i, todo_hrir) + i}; - ASSUME(todo > i); + const ALfloat (&input)[BUFFERSIZE] = data[c]; + const ALfloat (&Coeffs)[HRIR_LENGTH][2] = State->Chan[c].Coeffs; + ALfloat (&Values)[HRIR_LENGTH][2] = State->Chan[c].Values; + ALsizei Offset{State->Offset&HRIR_MASK}; - for(;i < todo;++i) + ALsizei HeadOffset{(Offset+IrSize-1)&HRIR_MASK}; + for(ALsizei i{0};i < BufferSize;) { - Values[HeadOffset][0] = 0.0f; - Values[HeadOffset][1] = 0.0f; - ++HeadOffset; - - const ALfloat insample{*(data++)}; - ApplyCoeffs(Offset, Values, IrSize, Coeffs, insample, insample); - - *(LeftOut++) += Values[Offset][0]; - *(RightOut++) += Values[Offset][1]; - ++Offset; + const ALsizei todo_hrir{HRIR_LENGTH - maxi(HeadOffset, Offset)}; + const ALsizei todo{mini(BufferSize-i, todo_hrir) + i}; + ASSUME(todo > i); + + for(;i < todo;++i) + { + Values[HeadOffset][0] = 0.0f; + Values[HeadOffset][1] = 0.0f; + ++HeadOffset; + + const ALfloat insample{input[i]}; + ApplyCoeffs(Offset, Values, IrSize, Coeffs, insample, insample); + + LeftOut[i] += Values[Offset][0]; + RightOut[i] += Values[Offset][1]; + ++Offset; + } + HeadOffset &= HRIR_MASK; + Offset &= HRIR_MASK; } - HeadOffset &= HRIR_MASK; - Offset &= HRIR_MASK; } } -- cgit v1.2.3