From 48fbad98369861985109764a530bc789e3a72170 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 8 May 2020 01:25:32 -0700 Subject: Slightly improve the Hann windows There's no need to include the 0 terms on the ends since they'll never contribute a sample. So extend the width to have the 0 terms just outside the window where it wouldn't contribute anyway. --- alc/effects/fshifter.cpp | 4 ++-- alc/effects/pshifter.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 1e7d1962..2ad98231 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -50,8 +50,8 @@ std::array InitHannWindow() /* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */ for(size_t i{0};i < HIL_SIZE>>1;i++) { - constexpr double scale{al::MathDefs::Pi() / double{HIL_SIZE-1}}; - const double val{std::sin(static_cast(i) * scale)}; + constexpr double scale{al::MathDefs::Pi() / double{HIL_SIZE}}; + const double val{std::sin(static_cast(i+1) * scale)}; ret[i] = ret[HIL_SIZE-1-i] = val * val; } return ret; diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index 375681df..a91fd2fb 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -56,8 +56,8 @@ std::array InitHannWindow() /* Create lookup table of the Hann window for the desired size, i.e. STFT_SIZE */ for(size_t i{0};i < STFT_SIZE>>1;i++) { - constexpr double scale{al::MathDefs::Pi() / double{STFT_SIZE-1}}; - const double val{std::sin(static_cast(i) * scale)}; + constexpr double scale{al::MathDefs::Pi() / double{STFT_SIZE}}; + const double val{std::sin(static_cast(i+1) * scale)}; ret[i] = ret[STFT_SIZE-1-i] = val * val; } return ret; -- cgit v1.2.3