Skip to main content

ContainerModel

Struct ContainerModel 

Source
pub struct ContainerModel { /* private fields */ }
Expand description

A bundle of pre-trained submodels selected by a quality threshold.

Each submodel covers values up to (but not including) its max_value. The last submodel is the fallback for values at or above the last threshold.

§Architecture

This implements the official NAM SlimmableContainer architecture (registered since file version 0.7.0). It is the format used by the mainstream A2 distribution (nano + standard bundle).

Implementations§

Source§

impl ContainerModel

Source

pub fn new( submodels: Vec<(f32, Box<StaticModel>)>, sample_rate: u32, ) -> Result<Self>

Creates a new ContainerModel.

§Requirements (enforced)
  • submodels must be non-empty.
  • Sorted by max_value ascending.
  • Last max_value must be >= 1.0.
Source

pub fn submodels(&self) -> &[(f32, Box<StaticModel>)]

Returns the list of (max_value, StaticModel ref) for diagnostics.

Source

pub fn submodels_mut(&mut self) -> &mut [(f32, Box<StaticModel>)]

Mutable access to submodels (for testing purposes only).

Source

pub fn active_index(&self) -> usize

Returns the index of the currently active submodel.

Source

pub fn set_active_index(&mut self, idx: usize)

Sets the active submodel index directly, bypassing crossfade (testing only).

Source

pub fn pending_index(&self) -> Option<usize>

Returns the index of the pending submodel during crossfade, if any.

Source

pub fn is_crossfading(&self) -> bool

Returns true if a crossfade is in progress.

Source

pub fn sample_rate(&self) -> u32

Returns the sample rate used to validate submodels.

Trait Implementations§

Source§

impl NamModel for ContainerModel

Source§

fn process(&mut self, input: &[f32], output: &mut [f32])

Invoked by the DSP RT-Thread to process acoustic sample blocks (Float32).
Source§

fn prewarm(&mut self, num_samples: usize)

“Heats up” the virtual tubes of the neural engine (prewarm).
Source§

fn reset(&mut self, sample_rate: u32, max_buffer_size: usize) -> Result<()>

Resets the model’s internal state with a new sample rate and max buffer size. Read more
Source§

fn set_max_buffer_size(&mut self, max_buf: usize) -> Result<()>

Reallocates internal buffers to support the given maximum block size. Read more
Source§

fn prewarm_samples(&self) -> usize

Returns the number of samples needed to fully stabilize the model’s internal state (receptive field / recurrent memory depth). Read more
Source§

fn prewarm_on_reset(&self) -> bool

Returns whether prewarm should be executed on reset(). Read more
Source§

fn set_prewarm_on_reset(&mut self, val: bool)

Sets whether prewarm should be executed on reset(). Read more
Source§

fn slimmable_breakpoints(&self) -> Vec<f64>

Returns the breakpoints at which slimmable quality transitions occur. Read more
Source§

impl SlimmableModel for ContainerModel

Source§

fn slimmable_breakpoints(&self) -> Vec<f64>

Returns the breakpoints at which slimmable quality transitions occur. Read more
Source§

fn set_slimmable_size(&mut self, val: f32, rt_status: Option<&RtStatusFlags>)

Sets the slimmable quality/size level. Read more

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.