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
impl ContainerModel
Sourcepub fn new(
submodels: Vec<(f32, Box<StaticModel>)>,
sample_rate: u32,
) -> Result<Self>
pub fn new( submodels: Vec<(f32, Box<StaticModel>)>, sample_rate: u32, ) -> Result<Self>
Creates a new ContainerModel.
§Requirements (enforced)
submodelsmust be non-empty.- Sorted by
max_valueascending. - Last
max_valuemust be>= 1.0.
Sourcepub fn submodels(&self) -> &[(f32, Box<StaticModel>)]
pub fn submodels(&self) -> &[(f32, Box<StaticModel>)]
Returns the list of (max_value, StaticModel ref) for diagnostics.
Sourcepub fn submodels_mut(&mut self) -> &mut [(f32, Box<StaticModel>)]
pub fn submodels_mut(&mut self) -> &mut [(f32, Box<StaticModel>)]
Mutable access to submodels (for testing purposes only).
Sourcepub fn active_index(&self) -> usize
pub fn active_index(&self) -> usize
Returns the index of the currently active submodel.
Sourcepub fn set_active_index(&mut self, idx: usize)
pub fn set_active_index(&mut self, idx: usize)
Sets the active submodel index directly, bypassing crossfade (testing only).
Sourcepub fn pending_index(&self) -> Option<usize>
pub fn pending_index(&self) -> Option<usize>
Returns the index of the pending submodel during crossfade, if any.
Sourcepub fn is_crossfading(&self) -> bool
pub fn is_crossfading(&self) -> bool
Returns true if a crossfade is in progress.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Returns the sample rate used to validate submodels.
Trait Implementations§
Source§impl NamModel for ContainerModel
impl NamModel for ContainerModel
Source§fn process(&mut self, input: &[f32], output: &mut [f32])
fn process(&mut self, input: &[f32], output: &mut [f32])
Source§fn prewarm(&mut self, num_samples: usize)
fn prewarm(&mut self, num_samples: usize)
prewarm).Source§fn reset(&mut self, sample_rate: u32, max_buffer_size: usize) -> Result<()>
fn reset(&mut self, sample_rate: u32, max_buffer_size: usize) -> Result<()>
Source§fn set_max_buffer_size(&mut self, max_buf: usize) -> Result<()>
fn set_max_buffer_size(&mut self, max_buf: usize) -> Result<()>
Source§fn prewarm_samples(&self) -> usize
fn prewarm_samples(&self) -> usize
Source§fn prewarm_on_reset(&self) -> bool
fn prewarm_on_reset(&self) -> bool
reset(). Read moreSource§fn set_prewarm_on_reset(&mut self, val: bool)
fn set_prewarm_on_reset(&mut self, val: bool)
reset(). Read moreSource§impl SlimmableModel for ContainerModel
impl SlimmableModel for ContainerModel
Source§fn slimmable_breakpoints(&self) -> Vec<f64>
fn slimmable_breakpoints(&self) -> Vec<f64>
Source§fn set_slimmable_size(&mut self, val: f32, rt_status: Option<&RtStatusFlags>)
fn set_slimmable_size(&mut self, val: f32, rt_status: Option<&RtStatusFlags>)
Auto Trait Implementations§
impl Freeze for ContainerModel
impl RefUnwindSafe for ContainerModel
impl Send for ContainerModel
impl Sync for ContainerModel
impl Unpin for ContainerModel
impl UnsafeUnpin for ContainerModel
impl UnwindSafe for ContainerModel
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.