AUDIO
Source snapshot · 11 November 2026

API reference / ravet_instrument::VoiceAllocator

Struct VoiceAllocator 

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>

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)

All notes/controllers/history clear; configuration remains.

pub fn finish(&mut self, index: usize) -> Result<(), VoiceError>

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.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<const N: usize> UnwindSafe for VoiceAllocator<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.