pub struct KarplusPluck<const N: usize> { /* private fields */ }Expand description
A plucked string voice with a fixed-capacity delay line of N samples.
N bounds the lowest playable frequency: at a given sample_rate_hz, frequencies below
sample_rate_hz / N clamp to the longest period the buffer can hold. For a 16 kHz engine,
N = 512 reaches down to ~31 Hz.
Implementations§
Source§impl<const N: usize> KarplusPluck<N>
impl<const N: usize> KarplusPluck<N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a stopped string voice. Call Self::pluck to start it ringing.
Sourcepub fn set_brightness_q8(&mut self, brightness_q8: u8)
pub fn set_brightness_q8(&mut self, brightness_q8: u8)
Sets the tone’s brightness/decay-speed balance. Lower values sound darker and decay faster.
Sourcepub fn set_decay_q8(&mut self, decay_q8: u8)
pub fn set_decay_q8(&mut self, decay_q8: u8)
Sets extra overall feedback loss per pass. 255 lets the string ring until re-plucked;
lower values shorten the sustain independently of brightness_q8.
Sourcepub fn pluck(
&mut self,
freq_hz: u32,
amplitude: i8,
duration_ms: u16,
sample_rate_hz: u32,
)
pub fn pluck( &mut self, freq_hz: u32, amplitude: i8, duration_ms: u16, sample_rate_hz: u32, )
Excites the string at freq_hz with a pseudo-random noise burst of amplitude, ringing
for duration_ms before auto-stopping (matching crate::synth::ToneVoice’s convention).
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether the string is still ringing (has not reached duration_ms or been stopped).
Sourcepub fn next_sample(&mut self) -> Option<i8>
pub fn next_sample(&mut self) -> Option<i8>
Advances the string by one sample, returning None once it has stopped.
Trait Implementations§
Source§impl<const N: usize> Clone for KarplusPluck<N>
impl<const N: usize> Clone for KarplusPluck<N>
Source§fn clone(&self) -> KarplusPluck<N>
fn clone(&self) -> KarplusPluck<N>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more