From 84cd061e9d3c8ed5db955433c157739082d5cf3d Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Thu, 26 May 2022 17:46:13 +0100 Subject: [PATCH] Avoid duplicate bin in the different scales --- src/finer/R3StretcherImpl.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/finer/R3StretcherImpl.cpp b/src/finer/R3StretcherImpl.cpp index 9c4236e..4521f33 100644 --- a/src/finer/R3StretcherImpl.cpp +++ b/src/finer/R3StretcherImpl.cpp @@ -597,12 +597,13 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop) // The frequency filter is applied naively in the frequency // domain. Aliasing is reduced by the shorter resynthesis // window - - double factor = m_parameters.sampleRate / double(fftSize); + + int lowBin = int(floor(fftSize * band.f0 / m_parameters.sampleRate)); + int highBin = int(floor(fftSize * band.f1 / m_parameters.sampleRate)); + if (highBin % 2 == 1) --highBin; + for (int i = 0; i < fftSize/2 + 1; ++i) { - double f = double(i) * factor; - if (f >= band.f0 && f < band.f1) { - //!!! check the mod 2 bit from stretch-fn + if (i >= lowBin && i < highBin) { scale->mag[i] *= winscale; } else { scale->mag[i] = 0.f;