From c6c046e81cd3b4dc405fb6ca5e360777250618ce Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Sat, 11 Oct 2025 08:23:39 +0900 Subject: [PATCH 1/5] Removes python 3.8 and adds 3.13 and 3.14. --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 79cd4c6..2952274 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -11,7 +11,7 @@ jobs: max-parallel: 12 matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v3 - name: Checkout submodules From 9798349cf8927156b4f444638392a722dd7e2fa1 Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Sat, 21 Mar 2026 23:38:47 +0900 Subject: [PATCH 2/5] Replaces output.resize by a view (issue #35). --- src/samplerate.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/samplerate.cpp b/src/samplerate.cpp index 42bb4d3..15329f1 100644 --- a/src/samplerate.cpp +++ b/src/samplerate.cpp @@ -183,11 +183,11 @@ class Resampler { // create a shorter view of the array if ((size_t)src_data.output_frames_gen < new_size) { - out_shape[0] = src_data.output_frames_gen; - output.resize(out_shape); + return output[py::slice(0, src_data.output_frames_gen, 1)] + .cast>(); + } else { + return output; } - - return output; } void set_ratio(double new_ratio) { @@ -312,11 +312,11 @@ class CallbackResampler { // create a shorter view of the array if (output_frames_gen < frames) { - out_shape[0] = output_frames_gen; - output.resize(out_shape); + return output[py::slice(0, output_frames_gen, 1)] + .cast>(); + } else { + return output; } - - return output; } void set_starting_ratio(double new_ratio) { @@ -413,8 +413,8 @@ py::array_t resample( // create a shorter view of the array if ((size_t)src_data.output_frames_gen < new_size) { - out_shape[0] = src_data.output_frames_gen; - output.resize(out_shape); + output = output[py::slice(0, src_data.output_frames_gen, 1)] + .cast>(); } if (verbose) { From 5ae5e8a94b32848a36408ce2a53a0ca15fb97744 Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Sat, 21 Mar 2026 23:39:15 +0900 Subject: [PATCH 3/5] Mark the GIL as not used for python 3.13+. --- src/samplerate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/samplerate.cpp b/src/samplerate.cpp index 15329f1..4e13133 100644 --- a/src/samplerate.cpp +++ b/src/samplerate.cpp @@ -430,7 +430,7 @@ py::array_t resample( namespace sr = samplerate; -PYBIND11_MODULE(samplerate, m) { +PYBIND11_MODULE(samplerate, m, py::mod_gil_not_used()) { m.doc() = "A simple python wrapper library around libsamplerate"; // optional // module From a687ad1df000d7c49fb4ed1e10b80d6b3f756879 Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Sun, 22 Mar 2026 15:55:28 +0900 Subject: [PATCH 4/5] Addressing review comments. --- src/samplerate.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/samplerate.cpp b/src/samplerate.cpp index 4e13133..6cb6a2e 100644 --- a/src/samplerate.cpp +++ b/src/samplerate.cpp @@ -183,11 +183,13 @@ class Resampler { // create a shorter view of the array if ((size_t)src_data.output_frames_gen < new_size) { - return output[py::slice(0, src_data.output_frames_gen, 1)] - .cast>(); - } else { - return output; + out_shape[0] = src_data.output_frames_gen; + return py::array_t( + out_shape, outbuf.strides, static_cast(outbuf.ptr), + output); } + + return output; } void set_ratio(double new_ratio) { @@ -312,11 +314,14 @@ class CallbackResampler { // create a shorter view of the array if (output_frames_gen < frames) { - return output[py::slice(0, output_frames_gen, 1)] - .cast>(); - } else { - return output; + out_shape[0] = output_frames_gen; + auto strides = std::vector(output.strides(), + output.strides() + output.ndim()); + return py::array_t( + out_shape, strides, static_cast(outbuf.ptr), output); } + + return output; } void set_starting_ratio(double new_ratio) { @@ -413,8 +418,10 @@ py::array_t resample( // create a shorter view of the array if ((size_t)src_data.output_frames_gen < new_size) { - output = output[py::slice(0, src_data.output_frames_gen, 1)] - .cast>(); + out_shape[0] = src_data.output_frames_gen; + auto base = output; + output = py::array_t( + out_shape, outbuf.strides, static_cast(outbuf.ptr), base); } if (verbose) { @@ -430,7 +437,7 @@ py::array_t resample( namespace sr = samplerate; -PYBIND11_MODULE(samplerate, m, py::mod_gil_not_used()) { +PYBIND11_MODULE(samplerate, m) { m.doc() = "A simple python wrapper library around libsamplerate"; // optional // module From 254dea4612b620d54ea4a3ba0d28e4483ad8c5e8 Mon Sep 17 00:00:00 2001 From: Tino Wagner Date: Sun, 22 Mar 2026 14:34:43 +0100 Subject: [PATCH 5/5] Fix Windows build --- src/samplerate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/samplerate.cpp b/src/samplerate.cpp index 6cb6a2e..1e766de 100644 --- a/src/samplerate.cpp +++ b/src/samplerate.cpp @@ -315,8 +315,8 @@ class CallbackResampler { // create a shorter view of the array if (output_frames_gen < frames) { out_shape[0] = output_frames_gen; - auto strides = std::vector(output.strides(), - output.strides() + output.ndim()); + auto strides = std::vector(output.strides(), + output.strides() + output.ndim()); return py::array_t( out_shape, strides, static_cast(outbuf.ptr), output); }