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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.