Struct Voice Allocator
pub struct VoiceAllocator<const N: usize> { /* private fields */ }Expand description
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.
Implementations§
§impl<const N: usize> VoiceAllocator<N>
impl<const N: usize> VoiceAllocator<N>
pub fn new(
mode: VoiceMode,
member_range: f32,
master_range: f32,
) -> Result<Self, VoiceError>
pub fn new( mode: VoiceMode, member_range: f32, master_range: f32, ) -> Result<Self, VoiceError>
Explicit bend ranges 0..96 semitones. Typical configured MPE ranges are member=48, master=2; polyphonic mode uses member range for channel bend.
pub fn voices(&self) -> &[Voice; N]
pub fn reset(&mut self)
pub fn reset(&mut self)
All notes/controllers/history clear; configuration remains.
pub fn finish(&mut self, index: usize) -> Result<(), VoiceError>
pub fn apply(&mut self, message: MidiMessage) -> VoiceChanges
pub fn apply(&mut self, message: MidiMessage) -> VoiceChanges
Apply one validated short MIDI message. Messages without implemented voice semantics are ignored. Sustain/sostenuto threshold is >=64. CC66 captures only held notes on its off-to-on transition. Either pedal can retain a released key; neither revives an already released tail. In MPE, both pedals are master-only and affect that zone. CC120 kills immediately, CC123 releases held notes respecting both pedals, CC121 resets relevant controllers and releases sustained notes. This is receiver policy, not a declaration of complete MIDI/MPE conformance.