From 9f349c21e702cb60dc6d75fdef2cc1b6e53780e9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 1 Mar 2021 01:03:44 -0800 Subject: Avoid cutting off the last bsinc filter coefficient --- core/bsinc_tables.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/bsinc_tables.cpp') diff --git a/core/bsinc_tables.cpp b/core/bsinc_tables.cpp index 8f375ac2..4ffb8fcb 100644 --- a/core/bsinc_tables.cpp +++ b/core/bsinc_tables.cpp @@ -171,19 +171,19 @@ struct BSincFilterArray { const double scale{hdr.scaleBase + (hdr.scaleRange * (si+1) / BSincScaleCount)}; const double cutoff{scale - (hdr.scaleBase * std::max(0.5, scale) * 2.0)}; const auto a = static_cast(hdr.a[si]); - const double l{a - 1.0}; + const double l{a - 1.0/BSincPhaseCount}; /* Do one extra phase index so that the phase delta has a proper * target for its last index. */ for(uint pi{0};pi <= BSincPhaseCount;++pi) { - const double phase{l + (pi/double{BSincPhaseCount})}; + const double phase{std::floor(l) + (pi/double{BSincPhaseCount})}; for(uint i{0};i < m;++i) { const double x{i - phase}; - filter[si][pi][o+i] = Kaiser(hdr.beta, x/a, hdr.besseli_0_beta) * cutoff * + filter[si][pi][o+i] = Kaiser(hdr.beta, x/l, hdr.besseli_0_beta) * cutoff * Sinc(cutoff*x); } } -- cgit v1.2.3