Skip to main content

WaveNet

Struct WaveNet 

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

A ready-to-run WaveNet, with all scratch buffers pre-allocated.

Implementations§

Source§

impl WaveNet

Source

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

Build a runnable model from a parsed .nam file.

All allocation happens here. Fails if the architecture is unsupported, an activation is unknown, or the flat weight blob does not match the config.

Source

pub fn receptive_field(&self) -> usize

Receptive field in samples: how far back the deepest dilated tap reaches.

This is the model’s warmup length and its processing latency. The first receptive_field() output samples of a fresh (or freshly reset) model are a startup transient computed against zero-filled history, so they reflect the streaming zero-init convention (matching NAM Core / NeuralAudio) rather than a training-time forward pass that pre-pads the whole input.

Source

pub fn sample_rate(&self) -> f64

The model’s sample rate (from the source .nam, or the NAM default).

Source

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

Process a buffer of mono samples in place.

Runs the block kernel: each MAX_BLOCK-sized chunk is pushed through one array (and one layer) at a time, keeping each weight matrix hot across the whole chunk. Bit-for-bit equivalent to looping Self::process_sample, and it shares the same streaming history, so the two are interchangeable.

Real-time contract: no heap allocation, locks, or syscalls. Enforced by tests/rt_safety.rs.

Source

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

Process a single mono sample, returning one output sample.

Equivalent to a one-element Self::process_buffer; convenient for callers that are not buffer-oriented. Allocation-free.

Source

pub fn reset(&mut self)

Reset all internal state (ring buffers) to silence.

Trait Implementations§

Source§

impl Debug for WaveNet

Source§

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

Formats the value using the given formatter. 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<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.