AUDIO
Source snapshot · 11 November 2026

API reference / ravet_instrument::SineInstrument

Struct SineInstrument 

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>

pub fn new(side: ZoneSide) -> 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>

Complete immutable Level schema; it does not describe voices/history.

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>

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>

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>

§

fn tail(&self) -> Tail

A held/sustained note can sound indefinitely until explicit note-off/pedal.

§

fn prepare(&mut self, config: ProcessConfig) -> Result<(), PrepareError>

§

fn process(&mut self, block: &mut ProcessBlock<'_, '_, '_>) -> ProcessStatus

§

fn reset(&mut self)

§

fn deactivate(&mut self)

§

fn start_audio(&mut self) -> Result<(), ProcessError>

Optional explicit audio-owner session start, after prepare and before rendering. Default is a no-op. Consumers using these hooks call once on the audio owner and stop there before transfer/deactivation. Failure must leave this processor stopped; earlier successful nodes may be stopped. Hooks follow prepared callback allocation/locking/I/O obligations. Existing adapters do not implicitly opt in; explicit graph sessions supply them.
§

fn stop_audio(&mut self)

End an explicitly started session on its audio owner, without deactivation or storage destruction. Default no-op; preparation/history may be retained.
§

fn try_reset(&mut self) -> Result<(), ProcessError>

Attempt history reset without allocating or changing configuration. Existing processors delegate to their successful legacy reset by default. A refusal may follow earlier reset work; consumers must remain faulted.
§

fn latency_samples(&self) -> u32

Prepared algorithmic latency in samples. Changes are advertised by adapters using their format’s restart/latency protocol outside the audio callback.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for SineInstrument<N>

§

impl<const N: usize> RefUnwindSafe for SineInstrument<N>

§

impl<const N: usize> Send for SineInstrument<N>

§

impl<const N: usize> Sync for SineInstrument<N>

§

impl<const N: usize> Unpin for SineInstrument<N>

§

impl<const N: usize> UnsafeUnpin for SineInstrument<N>

§

impl<const N: usize> UnwindSafe for SineInstrument<N>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.