diff options
author | Chris Robinson <[email protected]> | 2019-09-03 23:19:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-03 23:19:24 -0700 |
commit | 8940bbd034177182bb6fc1e3953e57674e488309 (patch) | |
tree | c0c51246eaae406d7fbf9514e8d699c7c0dfcc9b /alc/mixer/hrtfbase.h | |
parent | e1ee1bcde907e0021de38c1823fb5a67d49ebae9 (diff) |
Only use one accumulation buffer for B-Format HRTF mixing
It's all getting added together anyway and all channels are continuous inputs,
so this is fewer passes over various buffers.
Diffstat (limited to 'alc/mixer/hrtfbase.h')
-rw-r--r-- | alc/mixer/hrtfbase.h | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h index 82446714..5ae83fc9 100644 --- a/alc/mixer/hrtfbase.h +++ b/alc/mixer/hrtfbase.h @@ -108,29 +108,25 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu const ALsizei IrSize{State->IrSize}; ASSUME(IrSize >= 4); - auto chanstate = State->Chan.begin(); + auto accum_iter = std::copy_n(State->Values.begin(), State->Values.size(), AccumSamples); + std::fill_n(accum_iter, BufferSize, float2{}); + + auto coeff_iter = State->Coeffs.begin(); for(const FloatBufferLine &input : InSamples) { - const auto &Coeffs = chanstate->Coeffs; - - auto accum_iter = std::copy_n(chanstate->Values.begin(), - chanstate->Values.size(), AccumSamples); - std::fill_n(accum_iter, BufferSize, float2{}); - + const auto &Coeffs = *(coeff_iter++); for(size_t i{0u};i < BufferSize;++i) { const ALfloat insample{input[i]}; ApplyCoeffs(i, AccumSamples+i, IrSize, Coeffs, insample, insample); } - for(size_t i{0u};i < BufferSize;++i) - LeftOut[i] += AccumSamples[i][0]; - for(size_t i{0u};i < BufferSize;++i) - RightOut[i] += AccumSamples[i][1]; - - std::copy_n(AccumSamples + BufferSize, chanstate->Values.size(), - chanstate->Values.begin()); - ++chanstate; } + for(size_t i{0u};i < BufferSize;++i) + LeftOut[i] += AccumSamples[i][0]; + for(size_t i{0u};i < BufferSize;++i) + RightOut[i] += AccumSamples[i][1]; + + std::copy_n(AccumSamples + BufferSize, State->Values.size(), State->Values.begin()); } #endif /* MIXER_HRTFBASE_H */ |