This repository contains more detailed (and probably clear) description of how to use Magenta's RNN-Melody models with and without hardware MIDI keyboard. It guaranteed to work at least under Ubuntu 16.04.
This How-To based mostly on this official one.
Common:
-
Ubuntu 16.04
-
The machine learning library from Google Brain team based on Tensorflow to combine AI and Art.
-
RtMidi
RtMidi is a MIDI interface routines. It should be already installed if you used official Magenta installation script.
-
GUI for the JACK controls.
Optional:
-
The virtual MIDI keyboard that simulates the hardware one.
-
Software synthesizer for the virtual MIDI devices.
-
First, install Magenta manually following this instructions.
-
Install RtMidi and related packages:
sudo apt install build-essential libasound2-dev libjack-dev
sudo pip install --pre python-rtmidi
-
Install QjackCtl:
sudo apt install qjackctl
If you have no physical keyboard:
-
Install VMPK:
sudo apt install vmpk
-
Install FluidSynth:
sudo apt install fluidsynth
-
Launch QjackCtl and click the Start button.
-
Execute
sudo chown USER:USER /usr/share/sounds/sf2
where USER is your current system user (if you are working under the root, you probably don't needed in this step)
-
Run FluidSynth:
fluidsynth /usr/share/sounds/sf2/FluidR3_GM.sf2
-
If you are planning to use physical keyboard, plug it to the computer. Otherwise, launch VMPK.
-
If you are using VMPK:
- open
Edit
->Connections
- in the
Input MIDI Connection
chooseMidi Through
, inOutput MIDI Connection
chooseFLUID Synth
- open
-
In QjackCtl open Connections and make an apropriate routing:
- in
Audio
tab choosefluidsynth
on the left pad ("output ports") andsystem
on the right one ("input ports"), then tap connect - if you are using a virtual keyboard, on the
ALSA
tab connectVMPK Output
as an output port with theFLUID Synth
as the input one - if you are using a physical keyboard, connect its output with the
FLUID Synth
input
- in
Now you should be able to use (and hear) you keyboard (physical or virtual one) through the computer's audio output.
Attention! If you faced with some error during QjackCtl (and consequentally with the FluidSynth) startup, check in the Parameters
-> Interface
whether an appropriate sound card selected.
If everything ended up without troubles, you now have the appropriate software tuned to your hardware. The last preparation step is to download most sutable pre-learned model. Use one of the link bellow for download and store it in the MODEL_PATH:
First, look at the list of setup MIDI ports:
magenta_midi --list_ports
You should see a list of available input and output ports, including both the controller (e.g., VMPK) and synthesizer (e.g. FluidSynth) like that:
Input ports: 'Midi Through:Midi Through Port-0 14:0', 'VMPK Output:VMPK Output 128:0'
Ouput ports: 'FLUID Synth (8017):Synth input port (8017:0) 131:0', 'Midi Through:Midi Through Port-0 14:0', 'VMPK Input:VMPK Input 129:0'
You need to know the VMPK input port and FluidSynth output. Note, that the port is the full string name.
The last step is to launch the application:
magenta_midi \
--input_port=INPUT_VMPK_PORT \
--output_port=OUTPUT_FLUID_PORT \
--bundle_files=MODEL_PATH
You can find more bundle parameters there.
Magenta and its comunity doesn't stand still and the number of projects grows. This project allows you to play with the neural network on a par. Also taste this one which gives you a most comprehensive suite for the musical improvisation.