pub struct OversampleEngine { /* private fields */ }Expand description
RT-safe half-band oversampling engine.
Wraps 1–2 cascaded 2× stages. Off mode is zero-cost pass-through
(no state, infallible copy_nonoverlapping).
§Usage (per stereo channel)
// 1. Upsample model-rate input to oversampled rate
let n_os = engine.upsample(&input[..n_native], os_up_buf);
// 2. Model processes at oversampled rate
model.process(&os_up_buf[..n_os], &mut os_model_buf[..n_os]);
// 3. Downsample back to native rate
let n_out = engine.downsample(&os_model_buf[..n_os], output);Implementations§
Source§impl OversampleEngine
impl OversampleEngine
Sourcepub fn new(
factor: OversampleFactor,
max_input_samples: usize,
) -> Result<Self, NamErrorCode>
pub fn new( factor: OversampleFactor, max_input_samples: usize, ) -> Result<Self, NamErrorCode>
Creates a new engine with pre-allocated buffers.
max_input_samples: max block size at native model rate
(e.g., MAX_RESAMP_BUF = 8192).
Sourcepub fn factor(&self) -> OversampleFactor
pub fn factor(&self) -> OversampleFactor
Returns the current oversampling factor.
Sourcepub fn latency_samples(&self) -> usize
pub fn latency_samples(&self) -> usize
Returns the group delay in samples at the native (model) rate.
Each 2× half-band stage introduces HB_DELAY (= 12) samples. Off → 0, X2 → 12, X4 → 24.
Sourcepub fn upsample(&mut self, input: &[f32], output: &mut [f32]) -> usize
pub fn upsample(&mut self, input: &[f32], output: &mut [f32]) -> usize
Upsamples mono input from native rate to oversampled rate.
output must have room for input.len() * factor.multiplier() samples.
Returns number of oversampled samples written.
Sourcepub fn downsample(&mut self, input: &[f32], output: &mut [f32]) -> usize
pub fn downsample(&mut self, input: &[f32], output: &mut [f32]) -> usize
Downsamples mono input from oversampled rate back to native rate.
output must have room for input.len() / factor.multiplier() samples.
Returns number of native-rate samples written.
Auto Trait Implementations§
impl Freeze for OversampleEngine
impl RefUnwindSafe for OversampleEngine
impl Send for OversampleEngine
impl Sync for OversampleEngine
impl Unpin for OversampleEngine
impl UnsafeUnpin for OversampleEngine
impl UnwindSafe for OversampleEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.