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 5/01/2021, 1h15… )
(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,
killall -w a2jmidid
However, I have never tried this, as I don’t even have ‘
(Update 5/01/2021, 1h15: )
I must apologize, for the fact that I did not know something at the time I wrote the update from 12/07/2020 above. If the package ‘
a2jmidid‘ is in fact installed, on Debian versions ‘Stretch’ and later, starting JACK from QJackCtl will have as effect, automatically to forward all ALSA MIDI Ports to JACK MIDI, without requiring that the user enter any special parameters into the fields ‘Execute script after Startup’ or ‘Execute script on Shutdown’. The fact that this feature automatically gets invoked on JACK startup, at least via the GUI, would actually make it a fatal mistake, to add these lines into the fields as I previously suggested.
Further, when the package is installed and JACK launched, QJackCtl reveals that ALSA MIDI ports will get routed through, even if MIDI devices have been plugged in after JACK start. The following screen-shot shows this in action, as the two entries belonging to my Oxgen-61 Keyboard:
One fact which has already been documented elsewhere is that, when using the package ‘
a2jmidid‘, naming inconsistencies will result, for the JACK MIDI ports that are ‘created’. What I found in this one case was that, within Ardour, I was able to choose ‘midi_capture_2′ as input, as shown below (even though the choice was counter-intuitive, according to the QJackCtl GUI as shown before):
And, my Oxygen-61 played the Ardour Instrument for which I had done this. However, even though I saved the session reconfigured in this way, I have no real guarantee, that if I start JACK and then Ardour in the future, and load the same session, Ardour will really be reconnected with the same MIDI device.