Struct Sine Instrument
pub struct SineInstrument<const N: usize> { /* private fields */ }Expand description
Fixed 1..128-voice mono/stereo f32 sine instrument with no audio input. MIDI notes/sustain/sostenuto/stealing, opt-in chosen-side MPE negotiation and combined master/member bend drive phase-continuous oscillators. New/stolen notes reset phase/envelope. ADSR is fixed at 5 ms attack, 10 ms decay, 0.8 sustain and 50 ms release. Mix scales by level/N; stereo duplicates mono. Pressure and timbre remain available as snapshots but do not alter this sine reference.
Preparation accepts finite positive rates with ADSR counts fitting u32,
<=65,536 frames, <=1,024 input events, no
auxiliary/output-event buses. Complete blocks validate before mutation.
Note events quantize normalized velocity to MIDI seven-bit (positive rounds
to at least one); MIDI packets retain their wire velocity. Level clamps to
0..1 without smoothing. Unknown parameters and transport are ignored.
Bank/Program Change on the chosen side’s master (0 lower, 15 upper), even
before MPE negotiation, selects the three complete level programs with the
default SineOptions::apply_midi_programs policy. Self::with_options can
disable this Level replacement while preserving accepted raw bank/program
request observations and existing voice behavior. Other channels/unavailable
addresses preserve Level. Selection preserves voices/phase,
zone/ranges and envelopes; later level edits/requests win in event order.
Frequencies clamp to 49% of sample rate to stay below Nyquist. No state
codec, editor, device/format export, click-free stealing or deadline claim.
Reset/reprepare clear notes/history while preserving level and negotiated
configuration, clearing pending bank selectors. Accepted zone configurations
also clear selectors; bend-range changes preserve them. Process/reset use no heap,
blocking or I/O. There is no persisted current program identity or host menu.
Implementations§
§impl<const N: usize> SineInstrument<N>
impl<const N: usize> SineInstrument<N>
pub fn new(side: ZoneSide) -> Result<Self, VoiceError>
pub fn with_options(
side: ZoneSide,
options: SineOptions,
) -> Result<Self, VoiceError>
pub fn with_options( side: ZoneSide, options: SineOptions, ) -> Result<Self, VoiceError>
Construct with explicit program policy, preserving the ordinary voice, bank/request, pedal and negotiation behavior.
pub fn level(&self) -> f32
pub fn parameter_schema() -> ParameterSchema<'static, 1>
pub fn parameter_schema() -> ParameterSchema<'static, 1>
Complete immutable Level schema; it does not describe voices/history.
pub fn set_level(&mut self, value: f32) -> Result<(), ParameterError>
pub fn set_level(&mut self, value: f32) -> Result<(), ParameterError>
CONTROL-only exact Level replacement. Invalid/nonfinite or out-of-range values leave both Level and live synthesis history untouched.
pub fn last_program_request(&self, channel: u8) -> Option<MidiProgramRequest>
pub fn last_program_request(&self, channel: u8) -> Option<MidiProgramRequest>
Last negotiated raw Program Change request, even when automatic complete program application is disabled. Reset/reprepare clear these observations.
pub fn voices(&self) -> &[Voice; N]
pub fn programs(&self) -> ProgramBank<'static, 1>
pub fn programs(&self) -> ProgramBank<'static, 1>
Immutable reference catalogue; no mutable selection identity. Custom level edits change only level, and requests preserve existing voices.
Trait Implementations§
§impl<const N: usize> Processor for SineInstrument<N>
impl<const N: usize> Processor for SineInstrument<N>
§fn tail(&self) -> Tail
fn tail(&self) -> Tail
A held/sustained note can sound indefinitely until explicit note-off/pedal.