How to set the order of multiple usb midi devices in jack ? ?

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

Moderators: MattKingUSA, khz

Post Reply
pelorat
Established Member
Posts: 5
Joined: Fri Jun 09, 2017 2:31 pm

How to set the order of multiple usb midi devices in jack ? ?

Post by pelorat »

Hi,
I'm running Debian Stretch with the great KXStudio repos enabled. I have a usb soundcard (Focusrite Scarlett 2i4) as well as a usb midi interface (M-Audio Midisport) and a usb controller. All these devices appear as snd_usb_audio with

Code: Select all

cat /proc/asound/modules
At each boot, these devices get a different index number, which makes restoring jack sessions painful, since I have to figure out which midi port to use if I wanna, say, send a midi track to an external synth. Which is I would like to do, really.

To make things worse, even if I only connect my soundcard and my midi interface, which makes only 2 midi outputs, I have no less than 7 midi playbacks ports appearing in QJackCtl.

So, ideally, I would like to make sure that each time I boot the computer, midi playback ports in QjackCtl will remain the same so that I can rename the ones corresponding to my actual hardware and be able to flawlessly restore sessions.

I would gladly appreciate any help. Thanks in advance !
Jack Winter
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by Jack Winter »

What does cat /proc/asound/cards say?

You can use the name of the card (inside of brackets) instead of the index number, like hw:Intel or hw:USB.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux
pelorat
Established Member
Posts: 5
Joined: Fri Jun 09, 2017 2:31 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by pelorat »

Hi, thanks for your reply !

Here is the output of the command :

Code: Select all

0 [M1x1           ]: USB-Audio - MidiSport 1x1
                      M-Audio MidiSport 1x1 at usb-0000:00:1d.0-1.5, full speed
1 [USB            ]: USB-Audio - Scarlett 2i4 USB
                      Focusrite Scarlett 2i4 USB at usb-0000:00:1d.0-1.6, high speed
2 [DNSC2000       ]: USB-Audio - DN-SC2000
                      D&M DN-SC2000 at usb-0000:00:14.0-4, full speed
I tried to add these lines at the end of /usr/share/alsa/alsa.conf :

Code: Select all

options snd-usb-audio index=[hw:USB]
options snd-usb-audio index=[hw:M1x1]
options snd-usb-audio index=[hw:DNSC2000]
It had no effect, so I must have done something wrong. Is it the right file ? Is the syntax wrong ?

Thanks again for your time !
Jack Winter
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by Jack Winter »

pelorat wrote:Hi, thanks for your reply !

Here is the output of the command :

Code: Select all

0 [M1x1           ]: USB-Audio - MidiSport 1x1
                      M-Audio MidiSport 1x1 at usb-0000:00:1d.0-1.5, full speed
1 [USB            ]: USB-Audio - Scarlett 2i4 USB
                      Focusrite Scarlett 2i4 USB at usb-0000:00:1d.0-1.6, high speed
2 [DNSC2000       ]: USB-Audio - DN-SC2000
                      D&M DN-SC2000 at usb-0000:00:14.0-4, full speed
I tried to add these lines at the end of /usr/share/alsa/alsa.conf :

Code: Select all

options snd-usb-audio index=[hw:USB]
options snd-usb-audio index=[hw:M1x1]
options snd-usb-audio index=[hw:DNSC2000]
It had no effect, so I must have done something wrong. Is it the right file ? Is the syntax wrong ?

Thanks again for your time !
I don't know to be honest. I would add it to /etc/modprobe.conf (or what ever it's called on your system), since they are options when loading kernel modules. Try something like: options snd-usb-audio index=0,1,2 id=M1x1,USB,DNSC2000

But I think a better solution is referring to the card's names when using them. Like for jackd use hw:M1x1 or hw:USB, instead of hw:0 or hw:1.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by autostatic »

Code: Select all

$ modinfo snd-usb-audio | grep parm
parm:           index:Index value for the USB audio adapter. (array of int)
parm:           id:ID string for the USB audio adapter. (array of charp)
parm:           enable:Enable USB audio adapter. (array of bool)
parm:           vid:Vendor ID for the USB audio device. (array of int)
parm:           pid:Product ID for the USB audio device. (array of int)
parm:           device_setup:Specific device setup (if needed). (array of int)
parm:           ignore_ctl_error:Ignore errors from USB controller for mixer interfaces. (bool)
parm:           autoclock:Enable auto-clock selection for UAC2 devices (default: yes). (bool)
So you have to indicate a preferred index value and some kind of identifier for each device, Vendor and Product ID are an option:

Code: Select all

options snd-usb-audio index=1 vid=08bb pid=2706
options snd-usb-audio index=2 vid=xxxx pid=yyyy
options snd-usb-audio index=3 vid=xxxx pid=yyyy
You can list the Vendor and Product ID's with lsusb on the command-line:

Code: Select all

$ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 004: ID 8087:07dc Intel Corp. 
Bus 002 Device 006: ID 0bda:5752 Realtek Semiconductor Corp. 
Bus 002 Device 002: ID 06cb:0af8 Synaptics, Inc. 
Bus 002 Device 010: ID 08bb:2706 Texas Instruments PCM2706 Audio Codec
Bus 002 Device 009: ID 413c:3016 Dell Computer Corp. Optical 5-Button Wheel Mouse
Bus 002 Device 007: ID 060b:2401 Solid Year 
Bus 002 Device 005: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pelorat
Established Member
Posts: 5
Joined: Fri Jun 09, 2017 2:31 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by pelorat »

HI AutoStatic, thanks for your reply.

I've tried your method with no success. I think I am not editing the right file. So far I've tried :
  • /usr/share/alsa/alsa.conf
    /etc/modules
    /etc/asound.conf
none of which worked. None of these files look like the old /etc/modprobe.d/alsa-base.conf that I was accustomed with.

Is there any other file that I'm not aware of ?

Thanks !
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by autostatic »

Seems indeed you're not editing the right files. Does /etc/modprobe.d/ still exist? Then you could create a new file there, something like /etc/modprobe.d/midi-devices.conf and add the lines there.
pelorat
Established Member
Posts: 5
Joined: Fri Jun 09, 2017 2:31 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by pelorat »

Yes, /etc/modprobe.d/ still exists. There was only one file in there called oss-compat.conf. I tried created midi-devices.conf and copy the lines but that didn't change anything.
User avatar
noedig
Established Member
Posts: 239
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 54 times

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by noedig »

I don't know if this will fit your workflow, but I use a2jmidid as a bridge from ALSA MIDI to JACK MIDI.
Specifically, I use it as:

Code: Select all

a2jmidid -ue
-e causes it to bridge your hardware MIDI devices; -u causes it to remove the ALSA port numbering, thus the resulting JACK ports will not have the ALSA numbering and thus look the same after every reboot.
pelorat
Established Member
Posts: 5
Joined: Fri Jun 09, 2017 2:31 pm

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by pelorat »

HI noedig, thanks for your reply,
That is a good idea, I wasn't aware of that option. Is it possible to start this automatically when starting qjackctl, the same way than a2j_control, or do you have to manually launch the program every time ?
User avatar
noedig
Established Member
Posts: 239
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 54 times

Re: How to set the order of multiple usb midi devices in jack ? ?

Post by noedig »

Yes I'm sure you can just add it in the QJackCtl options. a2j_control controls a2jmidid, but I'm not sure how to use the -u option through a2j_control. I always just run a2jmidid directly, so I'm sure you can just replace a2j_control with a2jmidid -ue in your QJackCtl options.
Post Reply