## How to route a USB MIDI Keyboard to a JACK-MIDI Input, under Debian.

One of the possessions which I have is a USB MIDI Keyboard, which I’d like to be able to play, so that my computer’s software synthesizers actually generate the sound…

I know that this can be done because I’ve done it before. But in the past, when I set this up, I was either using an ‘ALSA’ MIDI input, belonging to an ‘ALSA’ or ‘PulseAudio’ application such as “Linux Multimedia Studio”, or I was using ‘QSynth’, which is a graphical front-end to ‘fluidsynth’, but in such a way that QSynth was listening for ALSA MIDI, and outputting JACK audio. This is actually a very common occurrence. I can switch between using the ‘PulseAudio’ and using the ‘JACK’ sound daemon, through a carefully set-up configuration of ‘QJackCtl’, which suspends PulseAudio when I activate JACK, and which also resumes PulseAudio, when I shut down JACK again.

But there is a basic obstacle, as soon as I want to play my MIDI Keyboard through ‘Ardour’. Ardour v6 can be run with the PulseAudio sound system, but only for playback, or, Ardour can be run with its JACK sound back-end, after JACK has been launched. Ardour cannot be run with its ALSA back-end, when PulseAudio is running.

The default behaviour of the Debian kernel modules, when I plug in a USB MIDI Keyboard, is, to make that MIDI connection visible within my system as an ALSA MIDI source, even though some applications, such as Ardour, will insist on only taking input from JACK MIDI sources, when in fact running in JACK mode. And so, this problem needed to be solved this morning…

The solution which I found was, to feed the Keyboard, which happens to be an “Oxygen 61″, to the ‘MIDI Through Port’ that’s visible in the ALSA Tab of QJackCtl’s Connections window. When MIDI sequences are fed there, they are also output from the System JACK MIDI sources, visible in the MIDI Tab of QJackCtl’s Connections window:

I should also note that, in many cases, the JACK clients can ask the JACK sound daemon to be connected to various inputs and outputs from within, without absolutely requiring that the QJackCtl Connections window be used. This explains why the audio output of Ardour was already routed properly to my PC’s speakers. But I found that I could only keep track of the MIDI connection, through QJackCtl’s Connections window. As the screen-shots above show, the second step is, to feed one of the System Sources to the appropriate Ardour MIDI input, in the MIDI Tab of QjackCtl’s Connections window.

The result was, that the synthesizer which I have available as an Ardour plug-in, played beautifully, in response to my pressing keys on the actual MIDI Keyboard, and no longer just, when I clicked on the graphical keyboard within the Ardour application window:

This on-screen keyboard can be made visible, by double-Alt-Clicking on the icon of the instrument, with Ardour in its Mixer view, and then expanding the resulting windows’ MIDI Keyboard fly-out. Yet, the on-screen keyboard was only useful for setup and testing purposes.

(Updated 12/07/2020, 17h20… )

## Another Reason, for me Not To Set Up JACK as the Back-End For PulseAudio

According to This Posting, I had written that hypothetically, it might make some sense for me to set up ‘JACK‘ as the back-end, by which ‘PulseAudio‘ sends its sound output, full-time. As opposed to the notion not making sense, to allow a few scripts to do so temporarily, that are being run by the ‘QJackCtl‘ GUI.

Well there is still a reason, why this might not be so. Doing so would be consistent, with setting up a Debian system completely according to our own preferences, and then if something does not work, we are up to our own devices to fix it.

My laptop ‘Klystron’ is a Kanotix / Spitfire system, which is also Debian-based, but in which the exact configuration has been done for me, by the Kanotix team, from their Live Disk (which can actually be written onto a USB-Key). This means that there is an advantage to me, in keeping certain configuration details conform to what the Kanotix people prescribed. If I did run into trouble with it, they would have some chance of maybe suggesting solutions, but only on the assumption that mine is still functioning within their parameters.

The way those parameters are, the current back-end to the PulseAudio sound server is displayed in the GUI as being “gstreamer“, and yet good compatibility with all things ALSA is maintained…

If I was to reconfigure my computers completely, for example because I wanted to change them to use the ‘GNOME desktop manager’ for instance, instead of ‘KDE‘, then the Kanotix team would say ‘Sorry, we are not familiar with the details of your system anymore. Therefore, we cannot help you.’

Yet, more generally, Debian allows deep changes to a configuration.

Dirk