midi_fundsp
Live performance synthesizer library
This crate assembles and integrates code from the midir, midi-msg, and cpal crates to enable the easy creation of live synthesizer software using fundsp for sound synthesis.
Using the crate involves setting up the following:
- An input thread to monitor MIDI events
- An output thread generating sounds that correspond to those events
- A table of fundsp sounds for the output thread to employ
- A
SegQueuethat enables those threads to communicate
Putting these pieces together yields the following introductory example program:
use ;
use SegQueue;
use AtomicCell;
use ;
use MidiInput;
use ;
The first four lines set up:
- A handle to the first MIDI input device it finds
- A messaging queue to connect the input and output threads
- A flag to instruct the threads to quit
The next two lines call start_input_thread() and start_output_thread() to
start the corresponding threads. The table of fundsp
sounds comes from midi_fundsp::sounds::options(), but a user can easily assemble their
own custom table of sounds as well.
Once the threads start, the program continues until the user enters a key, handling any incoming MIDI events as they arrive.
Other example programs show how to send different sounds to the left and right stereo channels and how to change the selection of synthesizer sound and MIDI input device while running.
Notes
- Always compile with
--release. Sound quality is poor when compiled with--debug. - The following MIDI messages are currently supported:
- Note On
- Note Off
- Pitch Bend
- Program Change
- Program change numbers correspond to indices in the
ProgramTable - These can originate either from a MIDI input device or from software
- Program change numbers correspond to indices in the
- All Notes Off
- All Sound Off