diff --git a/rubberband/RubberBandStretcher.h b/rubberband/RubberBandStretcher.h index 2227bee..91be842 100644 --- a/rubberband/RubberBandStretcher.h +++ b/rubberband/RubberBandStretcher.h @@ -805,10 +805,10 @@ public: * * Despite the existence of this call and its use of a size_t * argument, there is an internal limit to the maximum process - * buffer size that can be requested. This is currently 524288 (or - * 2^19). The Rubber Band API is essentially block-based and is - * not designed to process an entire signal within a single - * process cycle. + * buffer size that can be requested. Call getProcessSizeLimit() + * to query that limit. The Rubber Band API is essentially + * block-based and is not designed to process an entire signal + * within a single process cycle. * * Note that the value of "samples" refers to the number of audio * sample frames, which may be multi-channel, not the number of @@ -818,6 +818,16 @@ public: */ void setMaxProcessSize(size_t samples); + /** + * Obtain the overall maximum supported process buffer size in + * sample frames, which is also the maximum acceptable value to + * pass to setMaxProcessSize(). This value is fixed across + * instances and configurations. As of Rubber Band v3.3 it is + * always 524288 (or 2^19), but in principle it may change in + * future releases. + */ + size_t getProcessSizeLimit() const; + /** * Ask the stretcher how many audio sample frames should be * provided as input in order to ensure that some more output diff --git a/src/RubberBandStretcher.cpp b/src/RubberBandStretcher.cpp index a5e373f..930fd41 100644 --- a/src/RubberBandStretcher.cpp +++ b/src/RubberBandStretcher.cpp @@ -226,6 +226,13 @@ public: else m_r3->setMaxProcessSize(samples); } + size_t + getProcessSizeLimit() const + { + if (m_r2) return m_r2->getProcessSizeLimit(); + else return m_r3->getProcessSizeLimit(); + } + void setKeyFrameMap(const std::map &mapping) { @@ -492,6 +499,12 @@ RubberBandStretcher::setMaxProcessSize(size_t samples) m_d->setMaxProcessSize(samples); } +size_t +RubberBandStretcher::getProcessSizeLimit() const +{ + return m_d->getProcessSizeLimit(); +} + void RubberBandStretcher::setKeyFrameMap(const std::map &mapping) { diff --git a/src/faster/R2Stretcher.cpp b/src/faster/R2Stretcher.cpp index 1ad1eec..13b0956 100644 --- a/src/faster/R2Stretcher.cpp +++ b/src/faster/R2Stretcher.cpp @@ -316,6 +316,12 @@ R2Stretcher::setMaxProcessSize(size_t samples) reconfigure(); } +size_t +R2Stretcher::getProcessSizeLimit() const +{ + return 524288; +} + void R2Stretcher::setKeyFrameMap(const std::map &mapping) { diff --git a/src/faster/R2Stretcher.h b/src/faster/R2Stretcher.h index 3bda6f5..ea3ddab 100644 --- a/src/faster/R2Stretcher.h +++ b/src/faster/R2Stretcher.h @@ -73,6 +73,7 @@ public: void setExpectedInputDuration(size_t samples); void setMaxProcessSize(size_t samples); + size_t getProcessSizeLimit() const; void setKeyFrameMap(const std::map &); size_t getSamplesRequired() const; diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index 32fb8c1..ea1b2c8 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -652,6 +652,12 @@ R3Stretcher::setMaxProcessSize(size_t requested) ensureOutbuf(n * 8, false); } +size_t +R3Stretcher::getProcessSizeLimit() const +{ + return m_limits.overallMaxProcessSize; +} + void R3Stretcher::ensureInbuf(int required, bool warn) { diff --git a/src/finer/R3Stretcher.h b/src/finer/R3Stretcher.h index cea3742..5f9e560 100644 --- a/src/finer/R3Stretcher.h +++ b/src/finer/R3Stretcher.h @@ -93,6 +93,7 @@ public: void setExpectedInputDuration(size_t samples); void setMaxProcessSize(size_t samples); + size_t getProcessSizeLimit() const; void setDebugLevel(int level) { m_log.setDebugLevel(level); diff --git a/src/test/TestStretcher.cpp b/src/test/TestStretcher.cpp index cbf3ae3..5ab8049 100644 --- a/src/test/TestStretcher.cpp +++ b/src/test/TestStretcher.cpp @@ -46,8 +46,10 @@ BOOST_AUTO_TEST_CASE(engine_version) { RubberBandStretcher s2(44100, 1, RubberBandStretcher::OptionEngineFaster); BOOST_TEST(s2.getEngineVersion() == 2); + BOOST_TEST(s2.getProcessSizeLimit() == 524288); RubberBandStretcher s3(44100, 1, RubberBandStretcher::OptionEngineFiner); BOOST_TEST(s3.getEngineVersion() == 3); + BOOST_TEST(s3.getProcessSizeLimit() == 524288); } BOOST_AUTO_TEST_CASE(sinusoid_unchanged_offline_faster)