From 937990898267837a82cabfd62cebd794c46583ac Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Fri, 27 May 2022 11:34:35 +0100 Subject: [PATCH] Avoid excessive outhop when pitch shifting a long way --- src/finer/R3StretcherImpl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/finer/R3StretcherImpl.cpp b/src/finer/R3StretcherImpl.cpp index 9491f03..f19fed0 100644 --- a/src/finer/R3StretcherImpl.cpp +++ b/src/finer/R3StretcherImpl.cpp @@ -150,7 +150,10 @@ void R3StretcherImpl::calculateHop() { double ratio = getEffectiveRatio(); - double proposedOuthop = 256; + double proposedOuthop = 256.0; + if (proposedOuthop * m_pitchScale > 2048.0) { + proposedOuthop = 2048.0 / m_pitchScale; + } double inhop = 1.0; if (ratio > 1.0) { @@ -165,7 +168,7 @@ R3StretcherImpl::calculateHop() m_inhop = int(round(inhop)); - std::cout << "R3StretcherImpl::calculateHop: inhop " << m_inhop << ", mean outhop " << m_inhop * ratio << std::endl; + std::cout << "R3StretcherImpl::calculateHop: inhop = " << m_inhop << ", proposed outhop = " << proposedOuthop << ", mean outhop = " << m_inhop * ratio << std::endl; } double