Magenta MIDI Interface
This interface allows you to connect to a model generator via a MIDI controller and synthesizer. These can be either "hard" or "soft" components.
Note that you can only interface with a trained models that have a SequenceGenerator defined for them.
Before using the interface, you will need to install some dependencies. We have provided instructions for both Macintosh OS X and Ubuntu Linux.
For users of Macintosh OS X, the instructions below assume that you have installed Homebrew.
First, install Magenta. The rest of this document assumes you have
installed the Magenta pip package. Before continuing, make sure your
conda environment is active:
source activate magenta
The interface uses a python library called mido to interface your computer's MIDI hub. For it to work, you need to separately install a backend library it can use to connect to your system. Below are instructions for installing RtMidi. Note that if you used our installer script, RtMidi will already be installed.
sudo apt-get install build-essential libasound2-dev libjack-dev pip install --pre python-rtmidi
pip install --pre python-rtmidi
Install QjackCtl (Ubuntu Only)
QjackCtl is a tool that provides a graphical
interface for the JACK hub on Ubuntu to allow you to easily route signals
between MIDI components. You can install it using
sudo apt-get install
Connect/Install MIDI Controller
If you are using a hardware controller, attach it to the machine. If you do not have one, you can install a software controller such as VMPK by doing the following.
Ubuntu: Use the command
sudo apt-get install vmpk.
Mac: Download and install from the VMPK website.
Connect/Install MIDI Synthesizer
If you are using a hardware synthesizer, attach it to the machine. If you do not have one, you can install a software synthesizer such as FluidSynth using the following commands:
sudo apt-get install fluidsynth
brew install fluidsynth
If using FluidSynth, you will also want to install a decent soundfont. You can install one by doing the following:
Ubuntu: Use the command
sudo apt-get install fluid-soundfont-gm.
Mac: Download the soundfont from http://www.musescore.org/download/fluid-soundfont.tar.gz and unpack the SF2 file.
qjackctl. You'll probably want to do it in its own screen/tab
since it will print status messages to the terminal. Once the GUI
appears, click the "Start" button.
If using a software controller, you can launch it in the background or in its
own screen/tab. Use
vmpk to launch VMPK.
If using a software synth, you can launch it in the background or in its own screen/tab. Launch FluidSynth with the recommended soundfont installed above using:
In the QjackCtl GUI, click the "Connect" button. In the "Audio" tab, select your synthesizer from the list on the left (e.g., "fluidsynth") and select "system" from the list on the right. Then click the "Connect" button at the bottom.
If using a software controller (e.g., VMPK), launch it.
If using a software synth, launch it. Launch FluidSynth with the recommended soundfont downloaded above using:
Launching the Interface
After completing the installation and set up steps above have the interface list the available MIDI ports:
You should see a list of available input and output ports, including both the controller (e.g., "VMPK Output") and synthesizer (e.g., "FluidSynth virtual port").
To use the midi interface, you must supply a trained model bundle (.mag file). You can either download one from the links on our model pages (e.g., Melody RNN or create a bundle file from one of your training checkpoints using the instructions on the model page.
You will now start the interface with this command, supplying the location of the .mag bundle file and any additional flags required by the interaction (see below):
magenta_midi \ --input_port=<controller port> \ --output_port=<synthesizer port> \ --bundle_files=<bundle_file> \ --qpm=<quarters per minute> <additional interaction-specific args>
Assigning Control Signals
You can assign control change numbers to different "knobs" for controlling the interface in two ways.
- Assign the values on the command line using the appropriate flags (e.g.,
- Assign the values after startup by dynamically associating control changes
from your MIDI controller with different control signals. You can enter the UI
for doing this assignment by including the
--learn_controlsflag on the command-line at launch.
Using the "Call and Response" Interaction
"Call and response" is a type of interaction where one participant (you) produce a "call" phrase and the other participant (Magenta) produces a "response" phrase based upon that "call".
When you start the interface, "call" phrase capture will begin immediately. You will hear a metronome ticking and the keys will now produce sounds through your audio output.
When you would like to hear a response, you should stop playing and a wait a bar, at which point the response will be played. Once the response completes, call phrase capture will begin again, and the process repeats.
If you used the
--end_call_control_number flag, you can signal with that
control number and a value of 127 to end the call phrase instead of waiting for
a bar of silence. At the end of the current bar, a generated response will be
played that is the same length as your call phrase. After the response
completes, call phrase capture will begin again, and the process repeats.
Assuming you're using the Attention RNN bundle file and are using VPMK and FluidSynth, your command might look like this:
magenta_midi \ --input_port="VMPK Output" \ --output_port="FluidSynth virtual port" \ --bundle_files=/tmp/attention_rnn.mag \