pub struct BoxedResampler { /* private fields */ }Expand description
Self-contained Resampler that owns its coefficient buffer (std only).
Resampler borrows a ~24 KB caller-provided coefficient slice, which
makes it awkward to store as a long-lived struct field (the buffer must
outlive the resampler). BoxedResampler heap-allocates the coefficients
once and keeps them alive for the resampler’s whole lifetime, restoring
the pre-0.4 ergonomic new(input_rate, output_rate) + resample(..)
call shape for std users that hold resamplers in struct fields.
Implementations§
Source§impl BoxedResampler
impl BoxedResampler
Sourcepub fn new(input_rate: usize, output_rate: usize) -> Result<Self, CodecError>
pub fn new(input_rate: usize, output_rate: usize) -> Result<Self, CodecError>
Create a resampler that owns its polyphase filter coefficients.
Fails only for zero rates (the coefficient buffer is always sized correctly internally).
Sourcepub fn resample(&mut self, input: &[Sample]) -> PcmBuf
pub fn resample(&mut self, input: &[Sample]) -> PcmBuf
Convenience wrapper that allocates the output buffer.
Sourcepub fn resample_into(
&mut self,
input: &[Sample],
out: &mut [Sample],
) -> Result<usize, CodecError>
pub fn resample_into( &mut self, input: &[Sample], out: &mut [Sample], ) -> Result<usize, CodecError>
Resample into a caller-provided buffer (no allocation).
Sourcepub fn max_output_samples(&self, n_input: usize) -> usize
pub fn max_output_samples(&self, n_input: usize) -> usize
Upper bound on the output sample count for n_input input samples.