A CLI tool which reads notes from MIDI-IN and plays corresponding WAV samples to audio out
From https://github.com/RustAudio/cpal:
Note that on Linux, the ALSA development files are required. These are provided as part of the libasound2-dev package on Debian and Ubuntu distributions and alsa-lib-devel on Fedora.
For simplicity, the current CLI interface takes only 1 argument, the path to the SETTINGS file, which defaults to settings.json
. The SETTINGS file is expected to be valid json representing a single or comma separated list of the settings objects described below. For ease of use, the surrounding [
and ]
are implied and should not be included in the file.
{
"msb": 0-127, "lsb": 0-127, "pc": 1-128 // sets which program change will trigger this set of settings
"name": "A label for this set of samples", // currently only used for debugging
"samples": { // the mapping of note names to WAV files
"A0": "/home/pi/lightning-low.wav",
"C8": "/home/pi/lightning-high.wav",
...
}
}
Upon starting, it expects there to be no MIDI devices (to ensure that the audio device has connected cleanly) then waits for exactly 1 MIDI device to be connected. This device is then used as MIDI-IN.
In order to use multiple sets of samples, the sampler listens to MIDI program changes matching the msb/lsb/pc of each settings object in the SETTINGS file.
For instructions on how to run this on a Raspberry Pi Zero 2w, click here.