class samplerate_converter<T> dsp¶
template <typename T>
struct samplerate_converter { … } A template class for performing sample rate conversion on audio signals.
{'class': 'samplerate_converter'}This class supports both push and pull methods for resampling audio data. It maintains an internal state to handle contiguous signals split into buffers of varying sizes.
| T | The data type of the audio samples (e.g., float, double). |
typedef itype ¶
using itype = i64 Defined at dsp/sample_rate_conversion.hpp:69
typedef ftype ¶
using ftype = subtype<T> Defined at dsp/sample_rate_conversion.hpp:70
function window(ftype) ¶
Computes the Kaiser window function for a given sample position.
| n | Normalized sample position. |
| The window value. |
Defined at dsp/sample_rate_conversion.hpp:78
function sidelobe_att() ¶
Calculates the sidelobe attenuation based on the Kaiser beta parameter.
| Sidelobe attenuation in dB. |
Defined at dsp/sample_rate_conversion.hpp:87
function transition_width() ¶
Calculates the transition width based on sidelobe attenuation and depth.
| Transition width in radians. |
Defined at dsp/sample_rate_conversion.hpp:93
function filter_order(sample_rate_conversion_quality) ¶
static KFR_MEM_INTRINSIC size_t filter_order(sample_rate_conversion_quality quality) Computes the filter order for a given quality level.
| quality | The sample rate conversion quality. |
| The filter order as a size_t. |
Defined at dsp/sample_rate_conversion.hpp:104
function sidelobe_attenuation(sample_rate_conversion_quality) ¶
static KFR_MEM_INTRINSIC ftype sidelobe_attenuation(sample_rate_conversion_quality quality) Returns the sidelobe attenuation for a given quality level.
| quality | The sample rate conversion quality. |
| Sidelobe attenuation in dB. |
Defined at dsp/sample_rate_conversion.hpp:114
function transition_width(sample_rate_conversion_quality) ¶
static KFR_MEM_INTRINSIC ftype transition_width(sample_rate_conversion_quality quality) Returns the transition width for a given quality level.
| quality | The sample rate conversion quality. |
| Transition width in radians. |
Defined at dsp/sample_rate_conversion.hpp:124
function window_param(sample_rate_conversion_quality) ¶
static KFR_MEM_INTRINSIC ftype window_param(sample_rate_conversion_quality quality) Computes the Kaiser window parameter for a given quality level.
| quality | The sample rate conversion quality. |
| The Kaiser beta parameter. |
Defined at dsp/sample_rate_conversion.hpp:134
constructor samplerate_converter<T>(sample_rate_conversion_quality, itype, itype, ftype, ftype) ¶
samplerate_converter(sample_rate_conversion_quality quality, itype interpolation_factor,
itype decimation_factor, ftype scale = ftype(1), ftype cutoff = 0.5f) Constructs a sample rate converter.
| quality | The desired conversion quality. |
| interpolation_factor | Factor by which to interpolate the input signal. |
| decimation_factor | Factor by which to decimate the output signal. |
| scale | Scaling factor for the output (default: 1). |
| cutoff | Cutoff frequency as a fraction of the Nyquist frequency (default: 0.5). |
Defined at dsp/sample_rate_conversion.hpp:152
constructor samplerate_converter<T>() ¶
samplerate_converter() = default Defined at dsp/sample_rate_conversion.hpp:155
constructor samplerate_converter<T>(samplerate_converter<T> &&) ¶
samplerate_converter(samplerate_converter&&) noexcept = default Defined at dsp/sample_rate_conversion.hpp:156
function operator=(samplerate_converter<T> &&) ¶
samplerate_converter& operator=(samplerate_converter&&) noexcept = default Defined at dsp/sample_rate_conversion.hpp:157
function input_position_to_intermediate(itype) ¶
Converts an input position to an intermediate position.
| in_pos | Input position. |
| Intermediate position. |
Defined at dsp/sample_rate_conversion.hpp:164
function output_position_to_intermediate(itype) ¶
Converts an output position to an intermediate position.
| out_pos | Output position. |
| Intermediate position. |
Defined at dsp/sample_rate_conversion.hpp:174
function input_position_to_output(itype) ¶
Converts an input position to an output position.
| in_pos | Input position. |
| Corresponding output position. |
Defined at dsp/sample_rate_conversion.hpp:184
function output_position_to_input(itype) ¶
Converts an output position to an input position.
| out_pos | Output position. |
| Corresponding input position. |
Defined at dsp/sample_rate_conversion.hpp:194
function output_size_for_input(itype) ¶
Calculates the output size for a given input size (push method).
| input_size | Size of the input buffer. |
| Required output buffer size. |
Defined at dsp/sample_rate_conversion.hpp:204
function input_size_for_output(itype) ¶
Calculates the input size for a given output size (pull method).
| output_size | Size of the output buffer. |
| Required input buffer size. |
Defined at dsp/sample_rate_conversion.hpp:215
function skip(size_t, univector_ref<const T>) ¶
size_t skip(size_t output_size, univector_ref<const T> input) Skips a specified number of output samples, updating internal state.
| output_size | Number of output samples to skip. |
| input | Input buffer to consume. |
| Number of input samples consumed. |
Defined at dsp/sample_rate_conversion.hpp:227
function process(univector<T, Tag> &, univector_ref<const T>) ¶
template <univector_tag Tag>
size_t process(univector<T, Tag>& output, univector_ref<const T> input) Processes input data to produce resampled output (pull or push method).
| output | Output buffer to write resampled data. |
| input | Input buffer to read samples from. |
| Number of input samples processed. |
| Tag | Type tag for the univector output. |
Defined at dsp/sample_rate_conversion.hpp:255
function get_fractional_delay() ¶
Gets the fractional delay introduced by the resampler.
| Fractional delay in samples. |
Defined at dsp/sample_rate_conversion.hpp:264
function get_delay() ¶
Gets the integer delay introduced by the resampler.
| Delay in samples. |
Defined at dsp/sample_rate_conversion.hpp:270
variable kaiser_beta ¶
ftype kaiser_beta Kaiser window beta parameter.
Defined at dsp/sample_rate_conversion.hpp:272
variable depth ¶
itype depth Processing depth.
Defined at dsp/sample_rate_conversion.hpp:273
variable taps ¶
itype taps Number of filter taps.
Defined at dsp/sample_rate_conversion.hpp:274
variable order ¶
size_t order Filter order.
Defined at dsp/sample_rate_conversion.hpp:275
variable interpolation_factor ¶
itype interpolation_factor Interpolation factor.
Defined at dsp/sample_rate_conversion.hpp:276
variable decimation_factor ¶
itype decimation_factor Decimation factor.
Defined at dsp/sample_rate_conversion.hpp:277
variable filter ¶
univector<T> filter Filter coefficients.
Defined at dsp/sample_rate_conversion.hpp:278
variable delay ¶
univector<T> delay Delay line buffer.
Defined at dsp/sample_rate_conversion.hpp:279
variable input_position ¶
itype input_position Current input position.
Defined at dsp/sample_rate_conversion.hpp:282
variable output_position ¶
itype output_position Current output position.
Defined at dsp/sample_rate_conversion.hpp:283
function process_impl(univector_ref<T>, univector_ref<const T>) ¶
size_t process_impl(univector_ref<T> output, univector_ref<const T> input) Internal implementation of the process function.
| output | Output buffer slice. |
| input | Input buffer slice. |
| Number of input samples processed. |
Defined at dsp/sample_rate_conversion.hpp:291
Defined at dsp/sample_rate_conversion.hpp:67