Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving resampled data to out pointer instead of returning a copy #26

Open
eshaz opened this issue Feb 16, 2025 · 0 comments
Open

Saving resampled data to out pointer instead of returning a copy #26

eshaz opened this issue Feb 16, 2025 · 0 comments

Comments

@eshaz
Copy link

eshaz commented Feb 16, 2025

I'm working on a program that is using SharedMemory to send data between processes and it would be really nice if I could have samplerate just write directly to the buffer, so I don't have to copy it from the return result.

Thinking all that would be needed is to add an optional out parameter that, if present, is used instead of the below code.

// allocate output array
std::vector<size_t> out_shape{new_size};
if (inbuf.ndim == 2) out_shape.push_back(static_cast<size_t>(channels));
auto output = py::array_t<float, py::array::c_style>(out_shape);
py::buffer_info outbuf = output.request();

Looks like libsamplerate already supports setting the out pointer:

typedef struct
      {   float  *data_in, *data_out ;

          long   input_frames, output_frames ;
          long   input_frames_used, output_frames_gen ;

          int    end_of_input ;

          double src_ratio ;
      } SRC_DATA ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant