pub struct WaveNetModel<const CH: usize, const K: usize, const HEAD: usize> {
pub array1: WaveNetLayerArray<1, 1, CH, K, HEAD>,
pub array2: WaveNetLayerArray<CH, 1, HEAD, K, 1>,
pub head_scale: f32,
pub receptive_field_size: usize,
pub prewarm_on_reset: bool,
}Expand description
Complete WaveNet Model containing Two Heterogeneous Layer Array Blocks.
Scientific Reference: van den Oord, A., et al. (2016). “WaveNet: A Generative Model for Raw Audio.” DeepMind.
CH = Array1 channels (layer 0 of the JSON, e.g., 16 for Standard)
K = kernel size (always 3)
HEAD = Array1 head_size = Array2 channels (e.g., 8 for Standard)
Array2 uses HEAD channels and projects to 1 output (HEAD2=1),
following the C++ pattern: WaveNetLayerArrayT<CH, 1, 1, HEAD, K, Dilations, true>.
Fields§
§array1: WaveNetLayerArray<1, 1, CH, K, HEAD>Inner array 01: IN=1, COND=1, CH channels, HEAD outputs, no HeadBias.
array2: WaveNetLayerArray<CH, 1, HEAD, K, 1>Inner array 02: IN=CH, COND=1, HEAD channels, 1 output, with HeadBias.
head_scale: f32Final voltage compensation scale (Target Output Scale).
receptive_field_size: usizeLargest circular buffer required at the Kernel’s temporal root.
prewarm_on_reset: boolWhether to execute prewarm during reset(). Default: true.
Implementations§
Source§impl<const CH: usize, const K: usize, const HEAD: usize> WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> WaveNetModel<CH, K, HEAD>
Sourcepub fn set_effective_layers(&mut self, n: usize)
pub fn set_effective_layers(&mut self, n: usize)
Sets the effective number of layers on both arrays for soft-degrade.
Sourcepub fn backup_buffer_starts(&self, starts: &mut [usize], offset: &mut usize)
pub fn backup_buffer_starts(&self, starts: &mut [usize], offset: &mut usize)
Backs up the buffer_start pointers of both layer arrays into a slice.
Sourcepub fn restore_buffer_starts(&mut self, starts: &[usize], offset: &mut usize)
pub fn restore_buffer_starts(&mut self, starts: &[usize], offset: &mut usize)
Restores the buffer_start pointers of both layer arrays from a slice.
Sourcepub fn process(&mut self, input: &[f32], output: &mut [f32])
pub fn process(&mut self, input: &[f32], output: &mut [f32])
Resolves the full forward pass and produces waveform samples in zero allocation (DSP).
Combines the outputs of both arrays: sum(head1) + sum(head2) × head_scale.
For Scientists and Devs: The dispatch_simd! macro monomorphizes
this function via the SimdMath trait, matching the global hardware
configuration once at the call site. The compiler generates branchless
assembly optimized for your processor (AVX2, AVX-512, or AVX-512 VNNI BF16)
without v-table or dynamic dispatch overhead.
Sourcepub fn prewarm(&mut self)
pub fn prewarm(&mut self)
Stabilizes the model by processing silence (Zero Input) for pre-warm.
Dispatches via dispatch_simd! macro — a single static match on the
globally detected SIMD_MATH.instruction_set — to run the AVX2, AVX-512,
or AVX-512 VNNI BF16 kernel without runtime feature detection per call.
Sourcepub unsafe fn prewarm_avx512(&mut self)
pub unsafe fn prewarm_avx512(&mut self)
Prewarm strictly optimized for AVX-512 architecture.
§Safety
Requires a supported processor (AVX-512).
Sourcepub unsafe fn prewarm_avx2(&mut self)
pub unsafe fn prewarm_avx2(&mut self)
Trait Implementations§
Source§impl<const CH: usize, const K: usize, const HEAD: usize> NamModel for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> NamModel for WaveNetModel<CH, K, HEAD>
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 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§fn reset(&mut self, _sample_rate: u32, max_buffer_size: usize) -> Result<()>
fn reset(&mut self, _sample_rate: u32, max_buffer_size: usize) -> Result<()>
Auto Trait Implementations§
impl<const CH: usize, const K: usize, const HEAD: usize> Freeze for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> RefUnwindSafe for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> Send for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> Sync for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> Unpin for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> UnsafeUnpin for WaveNetModel<CH, K, HEAD>
impl<const CH: usize, const K: usize, const HEAD: usize> UnwindSafe for WaveNetModel<CH, K, HEAD>
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.