samplerate.lowlevel
– Lowlevel wrappers around libsamplerate¶
Lowlevel wrappers around libsamplerate.
The docstrings of the src_* functions are adapted from the libsamplerate header file.
-
samplerate.lowlevel.
src_callback_new
(callback, converter_type, channels)[source]¶ Initialisation for the callback based API.
Parameters: - callback (function) – Called whenever new frames are to be read. Must return a NumPy array of shape (num_frames, channels).
- converter_type (int) – Converter to be used.
- channels (int) – Number of channels.
Returns: - state – An anonymous pointer to the internal state of the converter.
- handle – A CFFI handle to the callback data.
- error (int) – Error code.
-
samplerate.lowlevel.
src_callback_read
(state, ratio, frames, data)[source]¶ Read up to frames worth of data using the callback API.
Returns: frames – Number of frames read or -1 on error. Return type: int
-
samplerate.lowlevel.
src_get_description
(converter_type)[source]¶ Return the description of the converter given by converter_type.
-
samplerate.lowlevel.
src_get_name
(converter_type)[source]¶ Return the name of the converter given by converter_type.
-
samplerate.lowlevel.
src_is_valid_ratio
(ratio)[source]¶ Return True if ratio is a valid conversion ratio, False otherwise.
-
samplerate.lowlevel.
src_new
(converter_type, channels)[source]¶ Initialise a new sample rate converter.
Parameters: - converter_type (int) – Converter to be used.
- channels (int) – Number of channels.
Returns: - state – An anonymous pointer to the internal state of the converter.
- error (int) – Error code.
-
samplerate.lowlevel.
src_process
(state, input_data, output_data, ratio, end_of_input=0)[source]¶ Standard processing function.
Returns non zero on error.
-
samplerate.lowlevel.
src_reset
(state)[source]¶ Reset the internal SRC state.
Does not modify the quality settings. Does not free any memory allocations. Returns non zero on error.
-
samplerate.lowlevel.
src_set_ratio
(state, new_ratio)[source]¶ Set a new SRC ratio.
This allows step responses in the conversion ratio. Returns non zero on error.
-
samplerate.lowlevel.
src_simple
(input_data, output_data, ratio, converter_type, channels)[source]¶ Perform a single conversion from an input buffer to an output buffer.
Simple interface for performing a single conversion from input buffer to output buffer at a fixed conversion ratio. Simple interface does not require initialisation as it can only operate on a single buffer worth of audio.