audio-processor-standalone-midi
This crate provides conversion into the VST types, which is to allow a VST host to use it. This is provided by the
MidiVSTConverter
.
Wraps midir
to provide MIDI input handling. The host may be started with MidiHost
.
When MIDI messages are received, they're pushed onto a lock-free atomic_queue::Queue
. The messages are picked-up in
the audio-thread by MidiAudioThreadHandler
.
It provides easy stand-alone MIDI integration with:
audio-processor-traits
-MidiEventHandler
traitrust-vst
-PluginInstance
Currently, MIDI messages over 3 bytes are dropped by this host. In addition, the queue is bounded & a size must be
provided. Default
implementations will use a MIDI queue capacity of 100.
This is a stand-alone MIDI host with helpers for doing real-time handling of MIDI messages in
the audio-thread and to integrate with VST plugins.
This is part of https://github.com/yamadapc/augmented-audio.
Memory Safety
In order to integrate with the VST C API, this crate does manual memory allocation and handling. This is due to VST event types being unrepresentable as safe Rust constructs (and due to real-time safety being required as well).
Real-time Safety
This crate provides the host
side, which is the MIDI host. This host allocates when it receives messages from midir
.
The events are forwarded onto a lock-free queue (atomic_queue
).
On the audio_thread
and vst
modules, past construction methods that should be called on the audio-thread will not
(de)-allocate. This is tested using the assert_no_alloc
crate.
In addition, basedrop
/ audio_garbage_collector
are used to prevent de-allocation from happening on the
audio-thread.
Test coverage
The crate has unit-tests (though it should be considered experimental as all of this repository).
Test coverage is at 80%.
Actix & Actors
The MidiHost
exposes an actix API, to be used with the actix actor system. This is to ease communicating with the midi
handler from multiple threads.
Usage
To use this crate:
- [
basedrop::Collector
] You'll need to set-upbasedrop
oraudio-garbage-collector
- [
host::MidiHost
] should be created- This will connect to inputs & push messages to a queue
- [
audio_thread::MidiAudioThreadHandler
] On your audio thread you should pop from the queue- This is enough to add MIDI to a standalone [
audio_processor_traits::MidiEventHandler
]
- This is enough to add MIDI to a standalone [
- [
vst::MidiVSTConverter
] If you're implementing a host, you'll have to convert messages onto the VST API
License: MIT