bbx_midi
MIDI message parsing and streaming utilities for audio applications.
Features
- MIDI message parsing: Parse raw MIDI bytes into structured messages
- Message type helpers: Extract note, velocity, pitch wheel, control data
- Real-time buffer: Pre-allocated buffer for use in audio callbacks
- Input streaming: Real-time MIDI input via
midir - FFI compatible:
#[repr(C)]types for C interop
Message Types
NoteOn/NoteOff- Note events with velocityControlChange- CC messages (mod wheel, sustain, etc.)PitchWheel- Pitch bend with 14-bit resolutionProgramChange- Instrument/patch changesPolyphonicAftertouch- Per-note pressureChannelAftertouch- Channel-wide pressure
MidiEvent
For sample-accurate MIDI timing in audio callbacks:
use ;
let event = MidiEvent ;
Used with PluginDsp::process() for synthesizer plugins.
Usage
use ;
// Parse raw MIDI bytes
let msg = new; // Note On, C4, velocity 100
if msg.get_status == NoteOn
// Pre-allocated buffer for real-time use
let mut buffer = new;
buffer.push;
for message in buffer.iter
buffer.clear; // Reset without deallocation
Cargo Features
streaming
Enables real-time MIDI input via midir:
[]
= { = "...", = ["streaming"] }
use ;
// Create stream with optional filters
let stream = new;
// Start listening (prompts for port selection)
let handle = stream.init;
Used by bbx_sandbox for terminal-based DSP testing with live MIDI input.
License
MIT