sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
Linear Resampler

sherpa-onnx provides a linear resampler for sample rate conversion through the SherpaOnnxCreateLinearResampler() API.

See also
SherpaOnnxCreateLinearResampler, SherpaOnnxDestroyLinearResampler
const SherpaOnnxLinearResampler *resampler =
SherpaOnnxCreateLinearResampler(48000, 16000, 0, 0);
// Process intermediate chunks (flush = 0)
SherpaOnnxLinearResamplerResample(resampler, input_samples, n, 0);
// Use out->samples[0..out->n-1]
// Flush the final chunk (flush = 1)
out = SherpaOnnxLinearResamplerResample(resampler, last_chunk, last_n, 1);
const SherpaOnnxLinearResampler * SherpaOnnxCreateLinearResampler(int32_t samp_rate_in_hz, int32_t samp_rate_out_hz, float filter_cutoff_hz, int32_t num_zeros)
Create a linear resampler.
const SherpaOnnxResampleOut * SherpaOnnxLinearResamplerResample(const SherpaOnnxLinearResampler *p, const float *input, int32_t input_dim, int32_t flush)
Resample one chunk of input audio.
void SherpaOnnxDestroyLinearResampler(const SherpaOnnxLinearResampler *p)
Destroy a linear resampler.
void SherpaOnnxLinearResamplerResampleFree(const SherpaOnnxResampleOut *p)
Destroy a resampler output chunk.
struct SherpaOnnxLinearResampler SherpaOnnxLinearResampler
Opaque linear resampler handle.
Definition c-api.h:3723
Output chunk returned by SherpaOnnxLinearResamplerResample().
Definition c-api.h:3773

If filter_cutoff_hz or num_zeros is 0, default values are used:

float min_freq = samp_rate_in_hz < samp_rate_out_hz ? samp_rate_in_hz
: samp_rate_out_hz;
float filter_cutoff_hz = 0.99f * 0.5f * min_freq;
int32_t num_zeros = 6;