MIDI controller guide
Midi controllers include a vast assortment of musical equipment including keyboards, pads, pot/fader controls and much more. It is possible to connect these devices via USB and other means to a computer in order to trigger and control sound and video for live performances, recording, and other purposes. There are two programs among many others that can play MIDI as a software synthesizer in Gentoo, these are media-sound/timidity++ and media-sound/fluidsynth. This article will only focus on timidity++.
Kernel drivers are usually required for external MIDI controller support such as interfacing with a MIDI keyboard or drum pads. The configuration below are examples for the legacy PC game/MIDI port and through USB, for other more exotic hardware try to find if the specific hardware is in the kernel module list.
Device Drivers ---> <*> Sound Card Support ---> <*> Advanced Linux Sound Architecture ---> <M> Sequencer Support <M> Sequencer dummy client ... <M> HR-timer backend support [*] Use HR-Timer as default sequencer timer ... (For the PC MIDI/game port) [*] Generic sound devices ---> ... (enable any special modules here) <M> Generic MPU-401 UART Driver ... (USB) [*] USB sound devices ---> <M> USB Audio/MIDI driver (enable any special modules here) ...
There are several USE flags in Gentoo enabling MIDI support for packages, to see a list of some packages which contain USE flags which contain the keyword
midi, the command quse from app-portage/portage-utils could be used.
quse -ve midi
emerge --ask timidity++
optionally, install the additional
emerge --ask fluid-soundfont
The available patchsets can be queried using
eselect timidity list
Available TiMidity++ patchsets:  fluid-soundfont  freepats
As an example, to set the
fluid-soundfont as the default patchset for the current user:
eselect timidity set 1
Starting the daemon
The timidity daemon can be run in user mode and need not be a system service:
timidity -iAD -Os
Timidity can be used with the JACK audio server. It must be started by the same user than the user running JACK, as example:
timidity -iA -B2,8 -Oj -EFreverb=0 -s 48000
Connecting midi ports
To begin using the midi controller, a midi input port must be connected to an output port. To see which input ports are available:
client 0: 'System' [type=kernel] 0 'Timer ' 1 'Announce ' client 14: 'Midi Through' [type=kernel] 0 'Midi Through Port-0' client 28: 'KOMPLETE KONTROL A49' [type=kernel,card=3] 0 'KOMPLETE KONTROL A49 MIDI 1'
the above is an example of what the output may look like. Here the midi controller is a Native Instruments Komplete Kontrol A49. Similarly, to see which output ports are available:
client 14: 'Midi Through' [type=kernel] 0 'Midi Through Port-0' client 28: 'KOMPLETE KONTROL A49' [type=kernel,card=3] 0 'KOMPLETE KONTROL A49 MIDI 1' client 128: 'TiMidity' [type=user,pid=5294] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 '
To connect directly to Timidity, use the following command:
aconnect 28:0 128:0
The connection can be verified using:
client 0: 'System' [type=kernel] 0 'Timer ' 1 'Announce ' client 14: 'Midi Through' [type=kernel] 0 'Midi Through Port-0' client 28: 'KOMPLETE KONTROL A49' [type=kernel,card=3] 0 'KOMPLETE KONTROL A49 MIDI 1' Connecting To: 128:0 client 128: 'TiMidity' [type=user,pid=5294] 0 'TiMidity port 0 ' Connected From: 28:0 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 '
If all went well, pressing a key on the midi controller should play a sound. This sound will depend on which timidity patchset is enabled using
To remove all connections, use:
To use a midi controller with Milkytracker, the package
media-libs/rtmidi is required. This package is not available in the official Gentoo repository, but can be found in several community overlays. Once
rtmidi has been installed, verify that the midi port is available:
... client 129: 'RtMidi Input Client' [type=user,pid=7350] 0 'RtMidi Input '
Once a midi controller has been connected to this port, Milkytracker will automatically recognize the controller.
Testing midi controller keys
If for some reason midi controller input is not producing any output, physical device failure can be ruled out using
media-sound/alsa-utils. First, identify the port of the midi controller:
then run the following:
aseqdump -p PORT
PORT is the port of the midi controller. Pressing any key on the controller should show up in the stdout. If no output is displayed, assuming the correct port was used, physical hardware failure may be to blame.
Unfortunately TiMidity++ has difficulties with PulseAudio.
Two possibilities to overcome the situation:
media-sound/pulseaudio and disable PulseAudio support if installed by removing the
pulseaudio use flag from your system configuration
media-sound/timidity++ with Libao support by activating the
ao use flag then run Timidity with
Furthermore once PulseAudio has been removed sound may be blocked when timidity is run as a system service. The solution seems to be that some soundcards require a dmix parameter in /etc/asound.conf: