pub struct Voice { /* private fields */ }Expand description
A pool voice: the sound generator plus allocator bookkeeping.
Implementations§
Source§impl Voice
impl Voice
Sourcepub fn new(sample_rate: f32, waveform: Waveform, env: AdsrEnvelope) -> Self
pub fn new(sample_rate: f32, waveform: Waveform, env: AdsrEnvelope) -> Self
Build an idle voice from a waveform + envelope template.
Sourcepub fn note_on(&mut self, note: u8, velocity: u8, freq_hz: f32, age: u64)
pub fn note_on(&mut self, note: u8, velocity: u8, freq_hz: f32, age: u64)
Assign a note to this voice. age is the allocator’s monotonic counter.
Sourcepub fn note_off(&mut self)
pub fn note_off(&mut self)
Release the note (envelope enters release; voice stays active until it decays).
Sourcepub fn render_sample(&mut self) -> f32
pub fn render_sample(&mut self) -> f32
Render one sample from this voice’s oscillator.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Voice
impl RefUnwindSafe for Voice
impl Send for Voice
impl Sync for Voice
impl Unpin for Voice
impl UnsafeUnpin for Voice
impl UnwindSafe for Voice
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
Mutably borrows from an owned value. Read more