Sending generated MIDI to FluidSynth

To send generated MIDI from Magenta to FluidSynth, we'll take one of the first examples we wrote in Chapter 2, Generating Drum Sequences with the DrumsRNN, and add some code to send the MIDI messages directly to the software synthesizer.

You can follow this example in the chapter_09_example_02.py file in the source code of this chapter. There are more comments and content in the source code, so you should go check it out.

This is similar to what we did in the previous chapter when we used the Web MIDI API to send MIDI notes to FluidSynth from the browser:

  1. First, we'll start FluidSynth using one of the following:
    • Linux: fluidsynth -a pulseaudio -g 1 PATH_TO_SF2
    • macOS: fluidsynth -a coreaudio -g 1 PATH_TO_SF2 ...

Get Hands-On Music Generation with Magenta now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.