Ensure tests actually exercise large input buffers

This commit is contained in:
Chris Cannam
2023-06-01 10:51:09 +01:00
parent f0b9061028
commit 173c7212f1

View File

@@ -270,6 +270,11 @@ static vector<float> process_realtime(RubberBandStretcher &stretcher,
} else if (available == 0) { // need to provide more input } else if (available == 0) { // need to provide more input
int required = stretcher.getSamplesRequired(); int required = stretcher.getSamplesRequired();
BOOST_TEST(required > 0); // because available == 0 BOOST_TEST(required > 0); // because available == 0
if (required < bs) {
// Because we sometimes want to explicitly test
// passing large blocks to process
required = bs;
}
int toProcess = std::min(required, n - inOffset); int toProcess = std::min(required, n - inOffset);
const float *const source = in.data() + inOffset; const float *const source = in.data() + inOffset;
bool final = (toProcess < required); bool final = (toProcess < required);
@@ -324,12 +329,13 @@ static void sinusoid_realtime(RubberBandStretcher::Options options,
// expected place // expected place
RubberBandStretcher stretcher(rate, 1, options, timeRatio, pitchScale); RubberBandStretcher stretcher(rate, 1, options, timeRatio, pitchScale);
stretcher.setMaxProcessSize(bs);
if (printDebug) { if (printDebug) {
stretcher.setDebugLevel(2); stretcher.setDebugLevel(2);
} }
stretcher.setMaxProcessSize(bs);
// The input signal is a fixed frequency sinusoid that steps up in // The input signal is a fixed frequency sinusoid that steps up in
// amplitude every 1/10 of the total duration - from 0.1 at the // amplitude every 1/10 of the total duration - from 0.1 at the
// start, via increments of 0.1, to 1.0 at the end // start, via increments of 0.1, to 1.0 at the end
@@ -665,15 +671,24 @@ BOOST_AUTO_TEST_CASE(sinusoid_realtime_long_blocksize_faster)
{ {
sinusoid_realtime(RubberBandStretcher::OptionEngineFaster | sinusoid_realtime(RubberBandStretcher::OptionEngineFaster |
RubberBandStretcher::OptionProcessRealTime, RubberBandStretcher::OptionProcessRealTime,
8.0, 1.5, 8.0, 0.5,
80000); 80000);
} }
BOOST_AUTO_TEST_CASE(sinusoid_realtime_long_blocksize_finer) BOOST_AUTO_TEST_CASE(sinusoid_realtime_long_blocksize_finer_stretch)
{ {
sinusoid_realtime(RubberBandStretcher::OptionEngineFiner | sinusoid_realtime(RubberBandStretcher::OptionEngineFiner |
RubberBandStretcher::OptionProcessRealTime, RubberBandStretcher::OptionProcessRealTime,
8.0, 1.5, 2.0, 1.0,
80000,
true);
}
BOOST_AUTO_TEST_CASE(sinusoid_realtime_long_blocksize_finer_shift)
{
sinusoid_realtime(RubberBandStretcher::OptionEngineFiner |
RubberBandStretcher::OptionProcessRealTime,
1.0, 0.5,
80000); 80000);
} }