Add getProcessSizeLimit

This commit is contained in:
Chris Cannam
2023-07-25 13:11:21 +01:00
parent 1eddafd7a7
commit c69c3b7473
7 changed files with 43 additions and 4 deletions

View File

@@ -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

View File

@@ -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<size_t, size_t> &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<size_t, size_t> &mapping)
{

View File

@@ -316,6 +316,12 @@ R2Stretcher::setMaxProcessSize(size_t samples)
reconfigure();
}
size_t
R2Stretcher::getProcessSizeLimit() const
{
return 524288;
}
void
R2Stretcher::setKeyFrameMap(const std::map<size_t, size_t> &mapping)
{

View File

@@ -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, size_t> &);
size_t getSamplesRequired() const;

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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)