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…

dsc_0001 email

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…

Screenshot_20201206_091955

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:

Screenshot_20201206_092022

Screenshot_20201206_092039

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:

Screenshot_20201206_092206

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.

Tada!

 

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

 

(As of 12/07/2020, 8h20: )

One fact which I should also mention is that, there exists the package ‘a2jmidid‘, which will solve the same sort of problem. When that package is installed – according to its package description – it causes a daemon to run, which will react to every ALSA, MIDI Input or Output port, by connecting to it, and creating a corresponding JACK MIDI Input or Output port.

That package was mainly meant to be used by people, who will entirely make MIDI connections from within their applications, and not using the ‘QJackCtl’ Connections window. And another big drawback of having that package installed will be, that it will automatically tie up all existing ALSA MIDI clients, to make them available to JACK… Therefore, that package can be counterproductive to install, if the user wants to switch back and forth, between having JACK running and not having it running.

 


 

(Update 12/07/2020, 17h20: )

I suppose that if a user is determined, to be switching back and forth between running ‘PulseAudio’ and ‘JACK’, and yet, wants the package ‘a2jmidid‘ to make all the ALSA-MIDI ports available as (forwarded) JACK-MIDI ports, then he or she can extrapolate on what I, myself have done, by adding more commands to ‘QJackCtl’. In the ‘Options’ tab, one can check the box named ‘Execute script after Startup’, and then in the field next to that tab, type:

 


a2jmidid -e &

 

(Note: The full path name of the executable may not be entered here.) Correspondingly, the user would also check the box named ‘Execute script on Shutdown’, and, to the right of that box, type:

 


killall -w a2jmidid

 

However, I have never tried this, as I don’t even have ‘a2jmidid‘ installed. :-)

Dirk

 

 

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>