diff --git a/src/RubberBandStretcher.cpp b/src/RubberBandStretcher.cpp index 2202832..575ae53 100644 --- a/src/RubberBandStretcher.cpp +++ b/src/RubberBandStretcher.cpp @@ -206,7 +206,8 @@ public: void setMaxProcessSize(size_t samples) { - if (m_r2) m_r2->setMaxProcessSize(samples); //!!! definitely need for r3d + if (m_r2) m_r2->setMaxProcessSize(samples); + else m_r3->setMaxProcessSize(samples); } void diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index dad5290..5bf0e1d 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -452,6 +452,23 @@ R3Stretcher::getSamplesRequired() const } } +void +R3Stretcher::setMaxProcessSize(size_t n) +{ + size_t oldSize = m_channelData[0]->inbuf->getSize(); + size_t newSize = m_guideConfiguration.longestFftSize + n; + + if (newSize > oldSize) { + m_log.log(1, "setMaxProcessSize: resizing from and to", oldSize, newSize); + for (int c = 0; c < m_parameters.channels; ++c) { + m_channelData[c]->inbuf = std::unique_ptr> + (m_channelData[c]->inbuf->resized(newSize)); + } + } else { + m_log.log(1, "setMaxProcessSize: nothing to be done, newSize <= oldSize", newSize, oldSize); + } +} + void R3Stretcher::process(const float *const *input, size_t samples, bool final) { @@ -505,8 +522,7 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final) size_t ws = m_channelData[0]->inbuf->getWriteSpace(); if (samples > ws) { - //!!! check this - m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve."); + m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve. Write space and samples", ws, samples); size_t newSize = m_channelData[0]->inbuf->getSize() - ws + samples; for (int c = 0; c < m_parameters.channels; ++c) { auto newBuf = m_channelData[c]->inbuf->resized(newSize); diff --git a/src/finer/R3Stretcher.h b/src/finer/R3Stretcher.h index 3f9cd4f..3625518 100644 --- a/src/finer/R3Stretcher.h +++ b/src/finer/R3Stretcher.h @@ -86,6 +86,8 @@ public: size_t getLatency() const; size_t getChannelCount() const; + + void setMaxProcessSize(size_t samples); void setDebugLevel(int level) { m_log.setDebugLevel(level);