From 810821a2216ac786eac602b47c21e638a35f4ace Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 31 Jul 2022 09:52:06 -0700 Subject: Simplify calculating nearest HRIR index --- core/hrtf.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/core/hrtf.cpp b/core/hrtf.cpp index 38c68cfa..3653c334 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -301,15 +301,8 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize, ir1offset + ((az1.idx+1) % Hrtf->elev[elev1_idx].azCount) }; - const std::array blend{{ - (1.0-elev0.blend) * (1.0-az0.blend), - (1.0-elev0.blend) * ( az0.blend), - ( elev0.blend) * (1.0-az1.blend), - ( elev0.blend) * ( az1.blend) - }}; - /* The largest blend factor serves as the closest HRIR. */ - const size_t irOffset{idx[std::max_element(blend.begin(), blend.end()) - blend.begin()]}; + const size_t irOffset{idx[(elev0.blend >= 0.5f)*2 + (az1.blend >= 0.5f)]}; ImpulseResponse res{Hrtf->coeffs[irOffset], Hrtf->delays[irOffset][0], Hrtf->delays[irOffset][1]}; -- cgit v1.2.3