AUDIO
Source snapshot · 11 November 2026

API reference / ravet_instrument

Crate ravet_instrument 

Expand description

Fixed-capacity voice ownership and configured MIDI 1.0 per-note expression. Explicit MPE negotiation and separate normalized/native performance ownership with portable f32/f64 reference sine synthesis. Device I/O and format export remain separate.

Structs§

Expression
Expression snapshots; released tails retain their last expression.
MidiProgramDecoder
Sixteen independent pending MIDI1 bank selectors and last request snapshots. CC0/32 update their own seven-bit half in either order, initially zero. Only Program Change emits a request, using the latest complete pending bank. Later bank changes never alter the last request. CC121/120/123 leave bank/program requests intact; explicit reset/System Reset clears both. Other messages are ignored. No implicit voice reset, program availability/commit, MPE mapping, callback scheduling, file/host/UI work or MIDI2 decoding. Fixed storage and bounded apply/reset/inspection use no heap, locks or I/O.
MidiProgramRequest
One received request, not proof that a consumer has a matching program. Channels/banks/programs are zero-based wire numbers. Repeated Program Change emits another request so the consumer can choose explicit recall behavior.
MpeReceiver
Fixed 1..128-slot shared-pool lower/upper MPE receiver. Starts in ordinary polyphony. RPN6 on channels 0/15 configures 0..15 members. Latest configuration wins overlaps by shrinking/disabling the other zone; an inactive master’s channel can become the other zone’s member. Every accepted configuration kills all occupied slots/controllers, including unrelated-zone tails, and resets changed zones’ bend ranges to 48/2.
MpeZone
Validated single MPE zone. Lower master=0, upper master=15 (zero-based).
NegotiatedChanges
Voice changes, accepted zone/range configuration and optional program request. A request does not commit sound state or alter voices; consumers perform exact catalogue lookup/publication under their own switching policy.
NegotiatedVoices
Explicit opt-in receiver for one chosen lower or upper MPE zone. Starts polyphonic with a two-semitone bend range. RPN6 on the chosen master enables 1..15 members or disables with zero; other masters and values >15 are ignored. Accepted zone messages kill all slots/controllers (including release tails), set member/master ranges to 48/2, and report changed occupied slots so the DSP owner can stop them. Disabling returns to polyphonic 2/2. Repeated valid zone messages also reset.
NoteKey
PerformanceBatchInfo
Immediate completions caused by input steals/chokes; does not include later DSP envelope completion. No output is published or storage reserved implicitly.
PerformanceChanges
Fixed results for one event. Completed targets retain the original address/ID. Completion is distinct from release; the consumer owns output delivery policy.
PerformanceExpression
Exact standard f64 replacement values, independent of DSP application. Defaults: volume/expression/brightness 1, pan .5, tuning/vibrato/pressure 0.
PerformanceSine
Independent mono/stereo no-input sine reference at native f32 or f64 precision.
PerformanceStart
The caller retriggers its DSP slot; a same-ID retrigger emits no old completion.
PerformanceVoice
One fixed slot. Owned targets always have concrete channel/key; ID is optional.
PerformanceVoices
Allocation-free 1..128-slot normalized/native performance receiver.
RpnDecoder
Fixed per-channel RPN selector and absolute Data Entry decoder. CC101/100 may arrive in either order. NRPN selection (CC99/98), CC121 and System Reset invalidate pending RPN data. Null RPN (127/127) emits nothing. Changing selection clears data; CC38 requires a preceding CC6 for that selection. Each CC6 infers an omitted LSB as zero. Increment/ decrement (CC96/97) and NRPN values are deliberately not decoded.
RpnUpdate
One absolute Data Entry update to a selected registered parameter.
SineInstrument
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.
SineInstrument64
Additive f64 facade over the same synthesis/voice/render kernel. Preparation, Level, envelope and wire velocities keep their existing scalar contracts; oscillator mix is published directly as f64 without an intermediate f32 output. This type leaves existing SineInstrument::new inference unchanged.
SineOptions
Reference MIDI program policy. The default applies the published complete programs to Level. Disabling application still updates negotiation/request observations and voices; only automatic global Level replacement is skipped.
Voice
One slot’s state. The DSP owner calls finish after its release envelope ends.
VoiceAllocator
Allocation-free 1..128-slot MIDI voice allocator. Polyphonic duplicate notes allocate separate voices; note-off releases the oldest held match. Steal order: idle, oldest released, oldest sustained, oldest held. Configured MPE allows one held note per member channel; a new note releases that channel’s old held/sustained notes before allocating. No RPN/zone configuration messages, MIDI 2.0, overlapping zones or DSP are implemented.
VoiceChanges
Changed-slot mask and optional start. A start can steal a previous note; caller resets/retriggers the DSP slot according to its own click policy.
VoiceStart

Enums§

PerformanceBatchError
PerformanceError
PerformancePhase
Key release keeps ownership until the DSP explicitly finishes the voice.
VoiceError
VoiceMode
VoicePhase
ZoneSide

Constants§

INSTRUMENT_LEVEL_ID
Permanent linear amplitude level ID, physical range 0..1, default 0.2.

Statics§

SINE_PROGRAMS
Public reference programs, zero-based MIDI bank 0/programs 0..2. IDs 1..3 remain stable independently of catalogue order. Each contains complete level state only: Default=0.2, Quiet=0.05, Full=1.0; no voice/history/zone reset.