Expand description
RT-safe audio resampling (rubato-based).
This crate defines the resampling layer — the Resampler trait is the
only processing interface that may be called directly from the real-time
(RT) audio thread. Codecs, DSP primitives, and graph nodes all perform
sample-rate conversion through this trait.
§Data layout — planar flat
Input and output are flat &[f32] buffers in planar layout:
[ch0_frames..., ch1_frames...]. This matches the layout of
audio_core_bsd::AudioFrame::samples, so an AudioFrame can be passed to
a Resampler directly with no extra copy or rearrangement. The channel
count is fixed when the implementation is constructed.
§Real-time safety boundary — CRITICAL
Only Resampler::process_into_buffer may be called from the RT thread. On
this path, heap allocation / locking / panicking / system calls are all
forbidden (same principle as the audio-core-bsd AudioNode RT contract).
Every buffer must be pre-allocated when the implementation is constructed.
Resampler::set_rate rebuilds the inner resampler to change the ratio and
therefore allocates. It must be called only from a configuration/worker
thread — never the RT thread, and only between audio cycles. The RT-alloc=0
guarantee applies only to process_into_buffer (the fixed-ratio path).
§Implementation status (0.2.0)
This crate provides the public API (Resampler trait / ResampleError)
and the rubato 4.0-backed standard implementation RubatoResampler.
RubatoResampler implements a zero-copy, allocation-free RT processing
path at a fixed input ratio (FixedSync::Input).
Re-exports§
pub use error::ResampleError;pub use error::Result;pub use resampler::Resampler;pub use rubato_impl::RubatoResampler;
Modules§
- error
- Resampling error types and the
Resultalias. - resampler
- Public resampling interface — the RT-safe processing boundary of this crate.
- rubato_
impl - RT-safe
Resamplerstandard implementation backed by the rubatoFftsynchronous resampler.