diff options
-rw-r--r-- | alc/hrtf.cpp | 2 | ||||
-rw-r--r-- | alc/hrtf.h | 13 | ||||
-rw-r--r-- | alc/mixer/hrtfbase.h | 26 |
3 files changed, 16 insertions, 25 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 5446c412..c0e2b982 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -438,7 +438,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuin { auto copy_arr = [](const std::array<double,2> &in) noexcept -> float2 { return float2{{static_cast<float>(in[0]), static_cast<float>(in[1])}}; }; - std::transform(tmpres[i].begin(), tmpres[i].end(), state->Chan[i].Coeffs.begin(), + std::transform(tmpres[i].begin(), tmpres[i].end(), state->Coeffs[i].begin(), copy_arr); } tmpres.clear(); @@ -79,19 +79,14 @@ struct HrtfFilter { struct DirectHrtfState { /* HRTF filter state for dry buffer content */ ALsizei IrSize{0}; - struct ChanData { - alignas(16) HrirArray Values; - alignas(16) HrirArray Coeffs; - }; - al::FlexArray<ChanData> Chan; + alignas(16) HrirArray Values; + al::FlexArray<HrirArray,16> Coeffs; - DirectHrtfState(size_t numchans) : Chan{numchans} { } - DirectHrtfState(const DirectHrtfState&) = delete; - DirectHrtfState& operator=(const DirectHrtfState&) = delete; + DirectHrtfState(size_t numchans) : Coeffs{numchans} { } static std::unique_ptr<DirectHrtfState> Create(size_t num_chans); static constexpr size_t Sizeof(size_t numchans) noexcept - { return al::FlexArray<ChanData>::Sizeof(numchans, offsetof(DirectHrtfState, Chan)); } + { return al::FlexArray<HrirArray,16>::Sizeof(numchans, offsetof(DirectHrtfState, Coeffs)); } DEF_PLACE_NEWDEL() }; 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 */ |