HOW-TO: MIDI audio on Fedora with FluidSynth

MIDI audio may not work out-of-the-box on Fedora. Most consumer-grade PCs and mobile devices do not have hardware capable of MIDI audio playback.

To address this issue, you can install FluidSynth, a modern MIDI software synthesizer.


Note 1:

If you intend to run Windows applications on Linux, you may be directed to install the wine package. Wine can also use a soft-synth for MIDI audio playback. If you do add the Fedora Wine package, it should pull fluidsynth in as a dependency and install it for you. Alternatively, you might prefer to add wine-core and fluidsynth separately for a leaner install.

Also, MAKE SURE to read the section Wine and MIDI.

Note 2:

If you are using traditional / mutable Fedora, you can add toolbox (if not already installed), and follow the “Atomic Fedora” instructions. This lets you experiment without heavily-modifying your current setup, and gives you an opportunity to learn some fundamentals about Fedora containers!


FluidSynth installation, inside & outside of a container

Fedora:

$ sudo dnf install fluidsynth

Atomic Fedora:

$ toolbox create
$ toolbox run sudo dnf upgrade
$ toolbox run sudo dnf install fluidsynth


Note 3:

If you prefer more isolation from you default container, for all the following examples, you can install FluidSynth into a separate, named container, such as toolbox create midi. You can then call (and script!) the container with the -c / --container flag, as in toolbox run -c midi ….


Now that FluidSynth is installed, spawn a MIDI server as a background daemon, and verify it’s up and running.

Fedora:

$ fluidsynth -is

Atomic Fedora:

$ toolbox run fluidsynth -is

You can safely kill the server by pressing Ctrl+C inside your terminal session, but don’t do so just yet.


In a separate terminal, verify your MIDI server using using pw-top.

$ pw-top

You should see output similar to the following:

S   ID  QUANT   RATE    WAIT    BUSY   W/Q   B/Q  ERR FORMAT           NAME
S   29      0      0    ---     ---   ---   ---     0                  Dummy-Driver
S   30      0      0    ---     ---   ---   ---     0                  Freewheel-Driver
S   38      0      0    ---     ---   ---   ---     0                  Midi-Bridge
R   44     64  44100  98.6us   7.8us  0.07  0.01   15    S32LE 2 44100 alsa_output.pci-0000_00_1b.0.hdmi-stereo
R   42     64  44100  60.9us  16.0us  0.04  0.01    0    S16LE 2 44100  + alsa_playback.fluidsynth

The text alsa_playback.fluidsynth means FluidSynth is running and ready to generate MIDI music!


Now that you have a MIDI server, you might find it convienient to launch it every time you log-in to your desktop session…

Autostart

If you installed fluidsynth system-wide, there’s a handy systemd service unit:

$ systemctl enable --now --user fluidsynth.service

You can disable it again with:

$ systemctl disable --now --user fluidsynth.service

Atomic Autostart

Currently, systemctl does not work in podman containers, and thus, systemctl does not work in toolbx.

Instead, you can create a background daemon using a bash script and a freedesktop.org Autostart entry.


Create a text file ~/.local/bin/podman-autostart with the following:

#!/usr/bin/env bash

podman container start fedora-toolbox-$(rpm -E %fedora) &&
toolbox run fluidsynth -is

Your script MUST be made executable to work:

$ chmod +x ~/.local/bin/podman-autostart


Finally, create a text file ~/.config/autostart/podman-autostart.desktop with the following:

[Desktop Entry]
Type=Application
Name=podman-autostart
Icon=application-x-executable-script
Exec=/home/<username>/.local/bin/podman-autostart

On a fresh login run:

$ toolbox list

Your podman container and MIDI server should be up and running:

a013c6db467a  fedora-toolbox-39  33 hours ago  running registry.fedoraproject.org/fedora-toolbox:39

Wine and MIDI

Wine relies on the Windows Registry to assign MIDI devices, and may require additional manual intervention. Assuming wine or wine-core are installed on the system or in a container.

Create a text file midi.reg with the following:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap]
"CurrentInstrument"="#128"

Then, use the regedit command to run the config:

Fedora:

$ regedit ./midi.reg

Atomic Fedora:

$ toolbox run regedit ./midi.reg

Related links

ArchWiki - MIDI

ArchWiki - FluidSynth

ArchWiki - Wine - MIDI Support

ArchWiki - XDG Autostart

WineHQ Wiki - MIDI

License

This work is marked with CC0 1.0

Removed server