Skip to main content

Model

Enum Model 

Source
#[non_exhaustive]
pub enum Model { WaveNet(Box<WaveNet>), Lstm(Lstm), Slimmable(Slimmable), }
Expand description

A runnable NAM model of any supported architecture.

Build with Model::from_nam; then call Model::process_buffer on the audio thread. #[non_exhaustive] so future architectures don’t break downstream matches.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

WaveNet(Box<WaveNet>)

A WaveNet model. Boxed so the enum’s variants are similarly sized (a WaveNet carries many pre-allocated scratch buffers); the indirection is one pointer hop off the build path, not the per-sample hot loop.

§

Lstm(Lstm)

An LSTM model.

§

Slimmable(Slimmable)

A width-selectable container of submodels.

Implementations§

Source§

impl Model

Source

pub fn from_nam(model: &NamModel) -> Result<Self, Error>

Build the runtime matching model.architecture. All allocation happens here.

Source

pub fn process_buffer(&mut self, io: &mut [f32])

Process a buffer of mono samples in place. Allocation-free.

Source

pub fn process_sample(&mut self, x: f32) -> f32

Process a single mono sample. Allocation-free.

Source

pub fn reset(&mut self)

Reset all internal state to the model’s initial conditions.

Source

pub fn receptive_field(&self) -> usize

The model’s processing latency in samples.

For WaveNet this is the receptive field: the first this-many output samples of a fresh (or freshly reset) model are a startup transient computed against zero history. A host can report it as plugin latency and/or discard that many leading samples. LSTM has no warmup, so this is 0.

Source

pub fn as_slimmable(&self) -> Option<&Slimmable>

The width-selectable container, if this model is one. Use it to drive the slim dial (Slimmable::select / Slimmable::set_slim_size); plain WaveNet/LSTM models return None.

Source

pub fn as_slimmable_mut(&mut self) -> Option<&mut Slimmable>

Mutable variant of Model::as_slimmable, for setting the active submodel.

Trait Implementations§

Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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