Basic Jack routing to USB Midi Interface Midi OUT

Unofficial support for the KXStudio Linux distribution and applications.
More info at http://kxstudio.linuxaudio.org/

Moderators: MattKingUSA, khz

Post Reply
starmandeluxe
Posts: 2
Joined: Tue Feb 17, 2015 12:26 am

Basic Jack routing to USB Midi Interface Midi OUT

Post by starmandeluxe »

Hello, newb here with a basic routing question that I can't wrap my head around. I want to route midi output from one of the sequencers in KXStudio such as the Non-sequencer, qmidiarp, etc. via Catia/Jack to my Komplete Audio 6 audio/midi interface so that it outputs the same.

So far, only Seq24 works because I can directly specify the midi device to use (in fact Seq24 doesn't show up at all in Catia/Jack). I'm using Catia currently to route audio and midi, and I tried first sending the midi out from the soft sequencer to "midi through", then to the midi output of my usb interface (it shows up in Catia/Jack just fine as an audio and midi module), which didn't work. I then thought that maybe I need to route the sequencer midi output into the usb interface's midi in, which didn't get me any output either.

I know this should be really simple, but I think I'm missing something. Any ideas? Do I need A2J?
varpa
Established Member
Posts: 509
Joined: Fri Feb 25, 2011 6:40 pm
Been thanked: 13 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by varpa »

There are 2 midi systems in linux: alsa midi which is what USB hardware uses and jack midi which is newer and better. If you run a2jmidid it will create connections between alsa midi and jack midi to allow interconnections. In kxstudio, in Cadence there is a tab to start/stop the Alsa midi bridge which starts a2jmidid for you. Be sure to select "Export HW"
starmandeluxe
Posts: 2
Joined: Tue Feb 17, 2015 12:26 am

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by starmandeluxe »

It worked! I had to stop and start the midi bridge in Cadence a few times but after that a2j started just fine. Thanks a lot!
tux99
Established Member
Posts: 346
Joined: Fri Sep 28, 2012 10:42 am
Contact:

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by tux99 »

varpa wrote:There are 2 midi systems in linux: alsa midi which is what USB hardware uses and jack midi which is newer and better.
Jack MIDI isn't 'better', each has a different purpose. ALSA MIDI is for communicating with physical MIDI devices (hardware synths, controllers, keyboards) while JACK MIDI is for interconnecting MIDI software (sequencers and soft synths) with each other.
So it's not about one or the other, it's about using each for it's specific purpose.
varpa
Established Member
Posts: 509
Joined: Fri Feb 25, 2011 6:40 pm
Been thanked: 13 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by varpa »

My statement that Jack midi is better is based on the fact it may have lower jitter than Alsa midi - see bottom of https://github.com/jackaudio/jackaudio. ... _and_Myths. Also it is not that hardware devices use alsa midi, the issue is that USB-midi devices use alsa. However, if you connect hardware with firewire then the devices use Jack midi. The reason linux has both is historic, alsa was first, and Jack later. In newer versions of Jack alsa midi devices will appear in Jack midi under the alsa_midi device -- similar to appearing under device a2j when you run a2jmidid -- in fact the a2jmidid code was incorporated into Jack. However, with alsa_midi devices are not discovered after Jack is started which is a bit annoying, though this will be fixed in the future.
tux99
Established Member
Posts: 346
Joined: Fri Sep 28, 2012 10:42 am
Contact:

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by tux99 »

varpa wrote:My statement that Jack midi is better is based on the fact it may have lower jitter than Alsa midi - see bottom of https://github.com/jackaudio/jackaudio. ... _and_Myths.
I would consider that FUD, when using hardware MIDI devices Jack has to go through ALSA so it certainly can't reduce jitter (unless it increases latency), if anything there is a risk that it adds to it.
Also it is not that hardware devices use alsa midi, the issue is that USB-midi devices use alsa. However, if you connect hardware with firewire then the devices use Jack midi.
Firewire MIDI devices are very rare and usually expensive, hardly mainstream. All mainstream MIDI devices are USB these days, and have been for the last 15 years.

Also I get the impression that it isn't clear to you that ALSA and Jack are not alternatives of each other. ALSA provides the hardware drivers (running in kernel mode) and a low layer API, while Jack is purely a user mode daemon and library.

That's why I said that ALSA is unavoidable when using MIDI hardware devices, while Jack is made for interconnecting various MIDI software sequencers, softsynths and other software tools. It's apples and oranges, each has a different function.
analoq
Established Member
Posts: 10
Joined: Sun Feb 08, 2015 8:21 pm
Location: Southern California

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by analoq »

tux99 wrote:Firewire MIDI devices are very rare and usually expensive, hardly mainstream. All mainstream MIDI devices are USB these days, and have been for the last 15 years.
If you restrict the definition to controllers then yes, but don't forget most Firewire audio interfaces have MIDI in/out on them. Which have come in handy quite often for me over the last 15 years :)

cheers.
varpa
Established Member
Posts: 509
Joined: Fri Feb 25, 2011 6:40 pm
Been thanked: 13 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by varpa »

This thread is getting unnecessarily heated. I myself don't really understand the technical details about the Jack midi jitter being less than alsa, though Paul Davis Jack/Ardour developer makes this claim so I take this statement seriously. However, I can't say that I've ever noticed a difference in jitter between alsa and jack midi, myself, and the link I sent before suggests it depends on specific hardware. Both alsa and jack are software there is no particular distinction that one is for software and one for hardware. Some synths, sequencers, etc support both (yoshimi, pianoteq), some only one (e.g. Ardour only does Jack, Qtractor only does alsa).
glowrak guy
Established Member
Posts: 2315
Joined: Sat Jun 21, 2014 8:37 pm
Been thanked: 251 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by glowrak guy »

Clarifying crucial definitions and presenting facts is informative, not heated.
tux99
Established Member
Posts: 346
Joined: Fri Sep 28, 2012 10:42 am
Contact:

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by tux99 »

varpa wrote:I myself don't really understand the technical details
Well there you go, why do you insist on arguing about something you don't understand?
I have been involved with Linux Audio and MIDI since the late '90s so I do know a thing or two about it. :wink:
analoq
Established Member
Posts: 10
Joined: Sun Feb 08, 2015 8:21 pm
Location: Southern California

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by analoq »

Rather than rely on arguments ad verecundiam, it would be interesting to test this out. I'm hardly the only person with both Firewire and USB MIDI devices so there exists overlap between ALSA MIDI and JACK MIDI which can be qualitatively compared, thusly one can be favored over the other.

Perhaps create a physical loopback connection between two hardware MIDI ports and send outbound messages at a set rate e.g. 20 Hz, then measure the rate of the inbound messages and compute the error. Run the experiment for both an ALSA MIDI device and a JACK Firewire MIDI device and see which had the greater error over the trial period.

There's several variables that would contribute but nonetheless it may be a good starting point to see if there is any discernable difference whatsoever and if so, try to isolate the cause.

cheers.
varpa
Established Member
Posts: 509
Joined: Fri Feb 25, 2011 6:40 pm
Been thanked: 13 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by varpa »

I asked Paul Davis for more details on the Jack/Alsa midi issue which you can find here: https://community.ardour.org/node/8641#comment-39066. Sounds like with modern linux kernels the jitter difference will likely be negligible.
tux99
Established Member
Posts: 346
Joined: Fri Sep 28, 2012 10:42 am
Contact:

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by tux99 »

Thanks for taking the time to ask Paul and he basically confirms what I said earlier in this thread.

I'm quoting his answer here as it's relevant for the thread:
JACK MIDI is internal to JACK, is entirely synchronous (messages generated by client A are given to client B during the same process callback) and delay free unless you have signal feedback loops. It is much less like any native MIDI system (ALSA on Linux, CoreAudio on OS X etc), and more like a highly customized messaging system designed specifically for low latency, real time music creation .... which of course is precisely what it is.

ALSA jitter is definitely hardware dependent, but it is not significantly affected on the system clock on any modern Linux kernel.

Of course, when discussing JACK MIDI that involves hardware I/O, then the weakest link in the chain is the one that matters, which will again be the ALSA driver and the hardware.
The last sentence is the one that matters most here: when using external hardware MIDI devices (which normally are USB connected these days) then JACK has to rely on ALSA, so you might as well use ALSA directly as that saves you one software layer (Jack) that is unnecessary and only introduces additional latency (no matter how small).

In brief: JACK is for software to software MIDI communication, ALSA is for software to external MIDI hardware communication.
j_e_f_f_g
Established Member
Posts: 2032
Joined: Fri Aug 10, 2012 10:48 pm
Been thanked: 357 times

Re: Basic Jack routing to USB Midi Interface Midi OUT

Post by j_e_f_f_g »

varpa wrote:I asked Paul Davis
LOL. Paul Davis' reply in summation: "What tux99 already told you."

BTW, ALSA's MIDI Sequencer API is an ill-conceived abomination. Microsoft once did the same thing with their MIDI Stream API (for XP), realized what a terrible idea it was, and quickly deprecated it. Pity ALSA's devs aren't as savvy. Any musing about the "jitter" in the dreadful, realtime-killing Seq API is a time-wasting joke.

You must use ALSA's RawMidi API for any serious work. The fact that the majority of linux devs use the seq api instead underscores how unaware most linux endusers/devs are of what linux subsystems do, how they really work, and how much things like mail lists, forums, and alleged "FUD FAQs" lead folks astray.

I urge people to download the alsa and jack source code, and thoroughly study it. Learn what it really does. I did, and was amazed (and too often horrified) by what I found, and by how much it differs from what most linux folks believe about it. The truth is in those sources.

Author of BackupBand at https://sourceforge.net/projects/backupband/files/
My fans show their support by mentioning my name in their signature.

Post Reply