Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/samplerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ 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 py::array_t<float, py::array::c_style>(
out_shape, outbuf.strides, static_cast<float *>(outbuf.ptr),
output);
}

return output;
Expand Down Expand Up @@ -313,7 +315,10 @@ class CallbackResampler {
// create a shorter view of the array
if (output_frames_gen < frames) {
out_shape[0] = output_frames_gen;
output.resize(out_shape);
auto strides = std::vector<py::ssize_t>(output.strides(),
output.strides() + output.ndim());
return py::array_t<float, py::array::c_style>(
out_shape, strides, static_cast<float *>(outbuf.ptr), output);
}

return output;
Expand Down Expand Up @@ -414,7 +419,9 @@ py::array_t<float, py::array::c_style> 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);
auto base = output;
output = py::array_t<float, py::array::c_style>(
out_shape, outbuf.strides, static_cast<float *>(outbuf.ptr), base);
}

if (verbose) {
Expand Down
Loading