Skip to content

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

@eshaz

Description

@eshaz

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 ;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions