From b07f74e5b9c989ae41d12b3ef2eb3869d4c066c3 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Thu, 26 May 2022 15:07:43 +0100 Subject: [PATCH] Add faster/finer option --- rubberband/RubberBandStretcher.h | 5 ++++- src/RubberBandStretcher.cpp | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/rubberband/RubberBandStretcher.h b/rubberband/RubberBandStretcher.h index 4b8355b..14529b9 100644 --- a/rubberband/RubberBandStretcher.h +++ b/rubberband/RubberBandStretcher.h @@ -317,7 +317,10 @@ public: OptionPitchHighConsistency = 0x04000000, OptionChannelsApart = 0x00000000, - OptionChannelsTogether = 0x10000000 + OptionChannelsTogether = 0x10000000, + + OptionEngineFaster = 0x00000000, + OptionEngineFiner = 0x20000000 // n.b. Options is int, so we must stop before 0x80000000 }; diff --git a/src/RubberBandStretcher.cpp b/src/RubberBandStretcher.cpp index 4a6d130..c94257c 100644 --- a/src/RubberBandStretcher.cpp +++ b/src/RubberBandStretcher.cpp @@ -27,21 +27,23 @@ namespace RubberBand { +//#define FASTER 1 RubberBandStretcher::RubberBandStretcher(size_t sampleRate, size_t channels, Options options, double initialTimeRatio, double initialPitchScale) : - /*!!! - m_d(new Impl(sampleRate, channels, options, - initialTimeRatio, initialPitchScale)) - */ - m_d(nullptr), - //!!! +logger - m_r3d(new R3StretcherImpl(R3StretcherImpl::Parameters(sampleRate, channels), - initialTimeRatio, - initialPitchScale)) + m_d + (!(options & OptionEngineFiner) ? + new Impl(sampleRate, channels, options, + initialTimeRatio, initialPitchScale) + : nullptr), + m_r3d + ((options & OptionEngineFiner) ? + new R3StretcherImpl(R3StretcherImpl::Parameters(sampleRate, channels), + initialTimeRatio, initialPitchScale) + : nullptr) { } @@ -183,6 +185,7 @@ float RubberBandStretcher::getFrequencyCutoff(int n) const { if (m_d) return m_d->getFrequencyCutoff(n); + else return {}; } void @@ -195,24 +198,28 @@ size_t RubberBandStretcher::getInputIncrement() const { if (m_d) return m_d->getInputIncrement(); + else return {}; } std::vector RubberBandStretcher::getOutputIncrements() const { if (m_d) return m_d->getOutputIncrements(); + else return {}; } std::vector RubberBandStretcher::getPhaseResetCurve() const { if (m_d) return m_d->getPhaseResetCurve(); + else return {}; } std::vector RubberBandStretcher::getExactTimePoints() const { if (m_d) return m_d->getExactTimePoints(); + else return {}; } size_t