From 320fb2f7fe8dad67916f0d2b47faff997015f7c9 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 20 Feb 2023 15:25:27 +0000 Subject: [PATCH 1/6] Ensure we consume when called with final=true and no samples - this was the default behaviour in R2 and also initially in R3 but changed when resample-before modes were added --- src/finer/R3Stretcher.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index 36da6b0..e56f3d2 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -679,7 +679,13 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final) int channels = m_parameters.channels; int inputIx = 0; - while (inputIx < int(samples)) { + if (samples == 0 && final) { + + m_log.log(2, "process: no samples but final specified, consuming"); + + consume(); + + } else while (inputIx < int(samples)) { int remaining = int(samples) - inputIx; int ws = m_channelData[0]->inbuf->getWriteSpace(); From 4ec2dad6e39470af1d01df95a011dd760ecc0013 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Wed, 8 Mar 2023 14:45:47 +0000 Subject: [PATCH 2/6] Fix hang toward end of processing, when faced with a file (e.g. some mp3s) for which libsndfile reports more frames from the header than are actually retrieved --- main/main.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index c355b6f..ce105c4 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -727,10 +727,12 @@ int main(int argc, char **argv) cerr << "Pass 1: Studying..." << endl; } - while (frame < sfinfo.frames) { + bool final = false; + + while (!final) { int count = -1; - if ((count = sf_readf_float(sndfile, ibuf, bs)) <= 0) break; + if ((count = sf_readf_float(sndfile, ibuf, bs)) < 0) break; for (size_t c = 0; c < channels; ++c) { for (int i = 0; i < count; ++i) { @@ -738,7 +740,10 @@ int main(int argc, char **argv) } } - bool final = (frame + bs >= sfinfo.frames); + final = (frame + bs >= sfinfo.frames); + if (count == 0) { + final = true; + } ts.study(cbuf, count, final); @@ -798,8 +803,10 @@ int main(int argc, char **argv) } } } + + bool final = false; - while (frame < sfinfo.frames) { + while (!final) { thisBlockSize = bs; @@ -836,8 +843,15 @@ int main(int argc, char **argv) } } - bool final = (frame + thisBlockSize >= sfinfo.frames); + final = (frame + thisBlockSize >= sfinfo.frames); + if (count == 0) { + if (debug > 1) { + cerr << "at frame " << frame << " of " << sfinfo.frames << ", read count = " << count << ": marking final as true" << endl; + } + final = true; + } + if (debug > 2) { cerr << "count = " << count << ", bs = " << thisBlockSize << ", frame = " << frame << ", frames = " << sfinfo.frames << ", final = " << final << endl; } From c51f6b1ae2543bb9e7ac9a108cb825c95d388abf Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Thu, 23 Mar 2023 17:26:28 +0000 Subject: [PATCH 3/6] Fix erroneous limits calculations --- src/finer/R3Stretcher.cpp | 4 ++-- src/finer/R3Stretcher.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index e56f3d2..dd996aa 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -382,10 +382,10 @@ R3Stretcher::calculateHop() m_log.log(1, "calculateHop: inhop and mean outhop", m_inhop, m_inhop * ratio); if (m_inhop < m_limits.maxInhopWithReadahead) { - m_log.log(1, "calculateHop: using readahead"); + m_log.log(1, "calculateHop: using readahead; maxInhopWithReadahead", m_limits.maxInhopWithReadahead); m_useReadahead = true; } else { - m_log.log(1, "calculateHop: not using readahead, inhop too long for buffer in current configuration"); + m_log.log(1, "calculateHop: not using readahead; maxInhopWithReadahead", m_limits.maxInhopWithReadahead); m_useReadahead = false; } } diff --git a/src/finer/R3Stretcher.h b/src/finer/R3Stretcher.h index d1b8308..5735db1 100644 --- a/src/finer/R3Stretcher.h +++ b/src/finer/R3Stretcher.h @@ -114,8 +114,8 @@ protected: minPreferredOuthop(roundUpDiv(rate, 512)), // 128 maxPreferredOuthop(roundUpDiv(rate, 128)), // 512 minInhop(1), - maxInhopWithReadahead(roundUpDiv(rate, 32)), // 1024 - maxInhop(roundUpDiv(rate, 32)) { // 1024 + maxInhopWithReadahead(roundUpDiv(rate, 64)), // 1024 + maxInhop(roundUpDiv(rate, 32)) { // 2048 if (options & RubberBandStretcher::OptionWindowShort) { // See note in calculateHop minPreferredOuthop = roundUpDiv(rate, 256); // 256 From b39ba8d518a4d98c853a7e8a257dc4a8445cc78e Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 27 Mar 2023 08:34:54 +0100 Subject: [PATCH 4/6] Update CHANGELOG for 3.1.3 --- CHANGELOG | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 44d6821..ba8a25e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,19 @@ +Changes in Rubber Band v3.1.3 + +This is a pure bug-fix release. + + * Fix failure to generate output when called with final=true and no + samples at input (a regression in v3.1, this worked correctly in + v3.0 and in the R2 engine) + * Fix occasional truncation of final block when using Speex resampler + * Fix hang in the command-line utility code at end of processing with + certain file formats + +The API is unchanged from 3.0 and the library is binary compatible +back to version 1.7. + + Changes in Rubber Band v3.1.2 This minor release contains a small number of build fixes. From bbed05108c0132807953be49a7755b6c2a9f8196 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 27 Mar 2023 08:35:16 +0100 Subject: [PATCH 5/6] This branch will be 3.1.3 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a624141..ed6cc21 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'Rubber Band Library', 'c', 'cpp', - version: '3.1.2', + version: '3.1.3', license: 'GPL-2.0-or-later', default_options: [ 'cpp_std=c++11', From 179dbd31c9ab6c0dda4059457c30b54e4184c776 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Mon, 27 Mar 2023 08:38:12 +0100 Subject: [PATCH 6/6] Update for 3.1.3 --- CHANGELOG | 3 ++- Doxyfile | 2 +- meson.build | 2 +- rubberband/RubberBandStretcher.h | 2 +- rubberband/rubberband-c.h | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ba8a25e..06e5dfc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ Changes in Rubber Band v3.1.3 -This is a pure bug-fix release. +This is a bug-fix release with no new features or changes to audio +quality. * Fix failure to generate output when called with final=true and no samples at input (a regression in v3.1, this worked correctly in diff --git a/Doxyfile b/Doxyfile index b73925b..41500a1 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = "Rubber Band Library" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 3.1.2 +PROJECT_NUMBER = 3.1.3 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/meson.build b/meson.build index ed6cc21..9cb83f4 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ project( meson_version: '>= 0.53.0' ) -rubberband_dynamic_library_version = '2.2.1' +rubberband_dynamic_library_version = '2.2.2' system = host_machine.system() architecture = host_machine.cpu_family() diff --git a/rubberband/RubberBandStretcher.h b/rubberband/RubberBandStretcher.h index 10e31ef..249567a 100644 --- a/rubberband/RubberBandStretcher.h +++ b/rubberband/RubberBandStretcher.h @@ -24,7 +24,7 @@ #ifndef RUBBERBAND_STRETCHER_H #define RUBBERBAND_STRETCHER_H -#define RUBBERBAND_VERSION "3.1.2" +#define RUBBERBAND_VERSION "3.1.3" #define RUBBERBAND_API_MAJOR_VERSION 2 #define RUBBERBAND_API_MINOR_VERSION 7 diff --git a/rubberband/rubberband-c.h b/rubberband/rubberband-c.h index 9be5bea..776e155 100644 --- a/rubberband/rubberband-c.h +++ b/rubberband/rubberband-c.h @@ -1,3 +1,4 @@ + /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* @@ -28,7 +29,7 @@ extern "C" { #endif -#define RUBBERBAND_VERSION "3.1.2" +#define RUBBERBAND_VERSION "3.1.3" #define RUBBERBAND_API_MAJOR_VERSION 2 #define RUBBERBAND_API_MINOR_VERSION 7