Skip to main content

OversampleEngine

Struct OversampleEngine 

Source
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

Source

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).

Source

pub fn factor(&self) -> OversampleFactor

Returns the current oversampling factor.

Source

pub fn is_bypass(&self) -> bool

Returns true when oversampling is bypassed (Off).

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.