Skip to main content

Crate sim_lib_midi_live

Crate sim_lib_midi_live 

Source
Expand description

Real-time MIDI buffering for the SIM music stack.

This crate provides fixed-capacity ring buffers that bridge real-time MIDI I/O into the MidiSource/ MidiSink traits: RingMidiBuffer acts as both source and sink, and RingTrackedMidiBuffer adds per-track tagging. When a buffer is full the oldest event is dropped and counted, so a slow consumer never blocks a real-time producer. The host-registered MidiLiveLib publishes these buffers as runtime plugin rows.

§Examples

A ring buffer accepts written events and yields them back in order:

use sim_lib_midi_live::RingMidiBuffer;
use sim_lib_midi_core::{
    MetaEvent, MidiEvent, MidiPayload, MidiSink, MidiSource, TickTime,
    synthetic_origin,
};

let mut buffer = RingMidiBuffer::new(480, 4).unwrap();
let event = MidiEvent {
    time: TickTime::new(0, 480).unwrap(),
    origin: synthetic_origin(),
    payload: MidiPayload::Meta(MetaEvent::EndOfTrack),
};
buffer.write(&event).unwrap();
assert_eq!(buffer.len(), 1);
assert_eq!(buffer.next().unwrap(), Some(event));

Structs§

LiveMidiSession
Public handle for an active live MIDI stream.
MidiLiveLib
Host-registered lib exposing the ring-buffer source/sink cards and their registry to a running runtime.
RingMidiBuffer
A fixed-capacity ring buffer of MidiEvents usable as both a MidiSource and a MidiSink.
RingTrackedMidiBuffer
A fixed-capacity ring buffer of TrackedMidiEvents usable as a TrackedMidiSource, tracking the highest track index seen.

Enums§

LiveMidiDirection
Direction exposed by a live MIDI session.
LiveMidiError
Errors raised when constructing live MIDI buffers.

Statics§

RECIPES
Cookbook recipes for this lib, embedded at build time.

Functions§

install_midi_live_lib
Installs MidiLiveLib into cx once and registers the ring-buffer source, sink, and tracked-source export records.