Struct Subtractive Synth
pub struct SubtractiveSynth { /* private fields */ }Expand description
Example mono/stereo f32 instrument with eight fixed MPE-aware voices.
Each voice runs oscillator -> low-pass VCF -> VCA. Its single ADSR drives VCA amplitude and VCF cutoff; MIDI velocity scales amplitude, combined bend retunes the oscillator, pressure adds up to 50% amplitude and CC74 opens the filter by up to 24 semitones. One shared voice pool accepts the existing two-zone MPE receiver’s RPN/pedal policy. New/stolen voices reset histories. Release finishes when the VCA envelope reaches zero; there is no separate filter tail. Mix scales by level/8, without an output limiter or headroom guarantee.
Prepared processing/reset allocate nothing. Up to 1024 frames and 128 MIDI events, no inputs/aux/output events, rates 8000..192000. Complete blocks validate before mutation. Parameter and UMP events are ignored; patches are an explicit separate prepared API. No MIDI 2.0 synthesis or plug-in export.
Implementations§
§impl SubtractiveSynth
impl SubtractiveSynth
pub fn new() -> Self
pub fn new() -> Self
Construct an inactive synth with the default saw patch.
pub fn set_patch(&mut self, patch: &SynthPatch) -> Result<(), PatchError>
pub fn set_patch(&mut self, patch: &SynthPatch) -> Result<(), PatchError>
Copy a predesigned patch without heap operations. Reject a mismatched active rate before mutation. ADSR changes apply only to subsequent notes; waveform changes retain phase and filter changes retain integrator history.
pub fn voices(&self) -> &[Voice; 8]
pub fn voices(&self) -> &[Voice; 8]
Voice expression snapshots; presentation belongs outside processing.
pub fn envelope_levels(&self) -> [f64; 8]
pub fn envelope_levels(&self) -> [f64; 8]
VCA/VCF’s shared instantaneous envelope levels, in voice-slot order.