diff --git a/src/RubberBandStretcher.cpp b/src/RubberBandStretcher.cpp index 5ebfadd..0327fa7 100644 --- a/src/RubberBandStretcher.cpp +++ b/src/RubberBandStretcher.cpp @@ -216,7 +216,7 @@ public: setExpectedInputDuration(size_t samples) { if (m_r2) m_r2->setExpectedInputDuration(samples); - //!!! perhaps also for R3 + else m_r3->setExpectedInputDuration(samples); } void diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index 4ac918a..dd2f947 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -47,6 +47,7 @@ R3Stretcher::R3Stretcher(Parameters parameters, m_unityCount(0), m_startSkip(0), m_studyInputDuration(0), + m_suppliedInputDuration(0), m_totalTargetDuration(0), m_consumedInputDuration(0), m_lastKeyFrameSurpassed(0), @@ -449,6 +450,7 @@ R3Stretcher::reset() m_prevOuthop = int(round(m_inhop * getEffectiveRatio())); m_studyInputDuration = 0; + m_suppliedInputDuration = 0; m_totalTargetDuration = 0; m_consumedInputDuration = 0; m_lastKeyFrameSurpassed = 0; @@ -479,6 +481,12 @@ R3Stretcher::study(const float *const *, size_t samples, bool) m_studyInputDuration += samples; } +void +R3Stretcher::setExpectedInputDuration(size_t samples) +{ + m_suppliedInputDuration = samples; +} + size_t R3Stretcher::getSamplesRequired() const { @@ -518,12 +526,19 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final) } if (!isRealTime()) { - + if (m_mode == ProcessMode::Studying) { m_totalTargetDuration = size_t(round(m_studyInputDuration * m_timeRatio)); m_log.log(1, "study duration and target duration", m_studyInputDuration, m_totalTargetDuration); + } else if (m_mode == ProcessMode::JustCreated) { + if (m_suppliedInputDuration != 0) { + m_totalTargetDuration = + size_t(round(m_suppliedInputDuration * m_timeRatio)); + m_log.log(1, "supplied duration and target duration", + m_suppliedInputDuration, m_totalTargetDuration); + } } // Update this on every process round, checking whether we've diff --git a/src/finer/R3Stretcher.h b/src/finer/R3Stretcher.h index 098f617..a5c537d 100644 --- a/src/finer/R3Stretcher.h +++ b/src/finer/R3Stretcher.h @@ -90,6 +90,7 @@ public: size_t getChannelCount() const; + void setExpectedInputDuration(size_t samples); void setMaxProcessSize(size_t samples); void setDebugLevel(int level) { @@ -303,6 +304,7 @@ protected: int m_startSkip; size_t m_studyInputDuration; + size_t m_suppliedInputDuration; size_t m_totalTargetDuration; size_t m_consumedInputDuration; size_t m_lastKeyFrameSurpassed;