pub struct OscillatorVoice { /* private fields */ }Expand description
A single monophonic voice: oscillator + envelope + velocity gain.
Frequency is supplied directly to note_on (Hz), so a tuning table can drive it;
callers wanting equal temperament compute the frequency upstream.
Implementations§
Source§impl OscillatorVoice
impl OscillatorVoice
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 with the given waveform and envelope shape.
Sourcepub fn note_on(&mut self, freq_hz: f32, velocity: u8)
pub fn note_on(&mut self, freq_hz: f32, velocity: u8)
Start a note at an explicit frequency (Hz) and MIDI velocity (0..=127).
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
true while the voice still contributes signal (attack..release).
Sourcepub fn velocity_gain(&self) -> f32
pub fn velocity_gain(&self) -> f32
Velocity gain currently applied (0..=1).
Sourcepub fn render_sample(&mut self) -> f32
pub fn render_sample(&mut self) -> f32
Render one sample and advance phase + envelope.
Trait Implementations§
Source§impl Clone for OscillatorVoice
impl Clone for OscillatorVoice
impl Copy for OscillatorVoice
Auto Trait Implementations§
impl Freeze for OscillatorVoice
impl RefUnwindSafe for OscillatorVoice
impl Send for OscillatorVoice
impl Sync for OscillatorVoice
impl Unpin for OscillatorVoice
impl UnsafeUnpin for OscillatorVoice
impl UnwindSafe for OscillatorVoice
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