Page 1 of 1

Multiple USB Sound Cards

Posted: Fri Dec 20, 2019 5:26 am
by oddy.o.lynx
I use a Fast Track Pro as my principle sound card in combination with a QuNexus and Artiphon Instrument 1, all three USB devices. I have disabled the on board sound card via the BIOS so it is does not compete with any of the USB cards. My system also loads the Loopback module, so in essence 4 sound cards loading at boot.

The QuNexus is strictly a MIDI instrument but the Artiphon Instrument 1 has built in speakers and I occasionally want to use those speakers with ALSA only and as the DEFAULT sound card (no JACK or PULSE running). To do this I want it to always be hw:0

The problem was the QuNexus was always grabbing hw:0 by default on every reboot and I would have to unplug and replug them to get them ordered properly, plug back the Artiphon first and then the QuNexus second to get the Artiphon Instrument 1 to get hw:0 and the QuNexus to take hw:1

The Fast Track Pro always grabs hw:5 as it uses the file

Code: Select all

/etc/modprobe.d/fast-track-pro.conf
with the following in it...

Code: Select all

options snd_usb_audio index=5 vid=0x763 pid=0x2012 device_setup=0x9 enable=1
to gets this configuration 24 BIT - 44.1/48 KHz - 2 INPUTS (ANALOG) - 4 OUTPUTS (ANALOG + DIGITAL)

It was easy enough to understand how this file was used to set the hw number for the Fast Track pro to hw:5. The dilemma was figuring a method to get the other two USB cards to be assigned the intended slot on reboot.

I tried a few times to make changes to the ~/.asoundrc to no avail. I figured that if the Fast Track Pro could be assigned a hw number there had to be a way to get the other two assigned without hot swapping and decided to determine if there was another way to do so other than asoundrc.

After re-reading a few articles at Alsa Opensrc Org discovered that by using the vid and pid, the slots could be assigned and there was no need for complicating things with alias char-major, alias sound-slot, alias sound-service and options snd-card. Getting the vid and pid were enough, and for both the QuNexus (vid=0x1f38 pid=0x0019) and Artiphon Instrument 1 (vid=0x04d8 pid=0xf296) this info can be found running lsusb

Code: Select all

lsusb
Bus 001 Device 009: ID 1f38:0019  
Bus 001 Device 008: ID 04d8:f296 Microchip Technology, Inc. 
Bus 001 Device 003: ID 0763:2012 M-Audio M-Audio Fast Track Pro

At first I tried creating .conf files in /etc/modprobe.d/ with this info but that did not work well
in those files mimicking the fast-track-pro.conf file added...

Code: Select all

options snd_usb_audio index=0 vid=0x04d8 pid=0xf296 enable=1
options snd_usb_audio index=1 vid=0x1f38 pid=0x0019 enable=1
but upon reboot the Fast Track Pro was at hw:0 and at its default 16 bit setting with the other cards (Aloop included) at hw:1, hw:2, hw:3
this was very far from a solution as I want the Fast Track Pro at 24 bit.

The solution was to add the following to

Code: Select all

/etc/modules
it already had

Code: Select all

snd-aloop
snd-seq-midi
by adding

Code: Select all

snd-usb-audio index=0 vid=0x04d8 pid=0xf296
snd-usb-audio index=1 vid=0x1f38 pid=0x0019
for

Code: Select all

cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

snd-aloop
snd-seq-midi
snd-usb-audio index=0 vid=0x04d8 pid=0xf296
snd-usb-audio index=1 vid=0x1f38 pid=0x0019
and to ensure the Asla Loopback card does not complicate things in

Code: Select all

cat /etc/modprobe.d/snd-aloop.conf
# Prevent snd-aloop from being loaded as first soundcard
options snd-aloop index=2
now every reboot the cards are ordered as intended

Code: Select all

cat /proc/asound/cards
 0 [INSTRUMENT1    ]: USB-Audio - INSTRUMENT1
                      Artiphon INSTRUMENT1 at usb-0000:00:1a.0-1.3, full speed
 1 [QuNexus        ]: USB-Audio - QuNexus
                      KESUMO, LLC QuNexus at usb-0000:00:1a.0-1.4, full speed
 2 [Loopback       ]: Loopback - Loopback
                      Loopback 1
 5 [Pro            ]: USB-Audio - FastTrack Pro
                      M-Audio FastTrack Pro at usb-0000:00:1a.0-1.1, full speed
sources:
https://alsa.opensrc.org/MultipleUSBAudioDevices
https://alsa.opensrc.org/MultipleCards

Re: Multiple USB Sound Cards

Posted: Sun Jan 16, 2022 4:52 pm
by oddy.o.lynx
I must apologize as my previous attempts were unsuccessful and the explanation way off base. I finally figured out how to get USB cards to always select preferred HW numbers either at boot or after unloading and loading modules via modprobe.

My intention is for the Artiphon1 to load as HW:0 or DEFAULT as it has an external speaker. The problem was that is has an on/off switch and if the computer booted with it off, another card would grab HW:0 and it would require hot swapping to realign them. I rarely use the built in audio card but keep it active nevertheless. The Fast Track Pro I want at HW:5 but also that it loads with 24 bit enabled. I also want to make sure that the QUNEXUS or any other card does not grab HW:0 other than the Artiphon1.

The root of the problem is that the FTP requires a configuration file to enable 24 bit support. There cannot be more than one configuration file for USB audio. My alternative up to now was to place the cards in order on the USB hub built into the computer. At boot everything would align with the FTP taking HW:5 and with 24 bit support and the Artiphon1 taking HW:0. However if the Artiphon1 was turned off or disconnected at boot it would be placed on another HW number other than 0 if turned on after boot. As mentioned, this would require hot swapping in order to get the desired setup, which is a bit of a PIA.

Aligning cards is not that complicated after all and assigning multiple USB audio cards to specific HW numbers is very doable.

First step is to get the VID and PID from each device using lsusb. They are the 4 digit hex values after ID. My system returns:

Code: Select all

lsusb
Bus 002 Device 003: ID 0763:2012 M-Audio M-Audio Fast Track Pro
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 046d:c03d Logitech, Inc. M-BT96a Pilot Optical Mouse
Bus 001 Device 003: ID 1f38:0019 KESUMO, LLC QuNexus
Bus 001 Device 005: ID 04d8:f296 Microchip Technology, Inc. INSTRUMENT1
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The current configuration has a built in audio card and aloop enabled as per KXstudio configuration.

/etc/modules looks like...

Code: Select all

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

snd_aloop
snd_seq_midi
snd_hda_intel
snd_usb_audio
The important item is snd_usb_audio

Next I have a few conf files in /etc/modprobe.d

intel.conf assigns the internal to HW:1

Code: Select all

options snd_hda_intel index=1
in this setup the preferred setting is aloop to HW:4 with a file named snd-aloop.conf

Code: Select all

options snd-aloop index=4
Previously, for the Fast Track Pro, to use 24 bit it require a configuration file with this line in it:

Code: Select all

options	snd_usb_audio	vid=0x763 pid=0x2012 device_setup=0x9 index=5 enable=1
device_setup=0x9 enables 24 bit and is needed

This is where I ran into the problem. Adding more than one configuration file will not work. If there are more than one .conf file with

Code: Select all

options	snd_usb_audio

on boot the system will only enable one of the files, generally the one that has HW:0 and move on. The remaining USB audio cards will grab HW numbers in succession. As well, if I create a configuration file setting the ARTIPHON1 to HW:0 the FTP loads at 16 bit and does not grab HW:5.

Long story short... to align multiple usb audio cards in an intended order, first step is to add the line

Code: Select all

snd_usb_audio
to the file /etc/modules
to ensure the audio cards get loaded at boot

and create one file in /etc/modprobe.d/ for all USB cards, named something like usb-audio.conf
one file can have all the USB audio cards configuration included

In my case, to get the 3 usb audio cards placed as intended...

to recap, from lsusb the three cards are:

Code: Select all

Bus 002 Device 003: ID 0763:2012 M-Audio M-Audio Fast Track Pro
Bus 001 Device 003: ID 1f38:0019 KESUMO, LLC QuNexus
Bus 001 Device 005: ID 04d8:f296 Microchip Technology, Inc. INSTRUMENT1
the line to add with all 3 cards is as follows into /etc/modprobe.d/usb-audio.conf:

Code: Select all

options	snd_usb_audio vid=0x763,0x4d8,0x1f38 pid=0x2012,0xf296,0x19 index=5,0,2 device_setup=0x9
It's important that vid and pid have the respective values without typos and in order

this section vid=0x763,0x4d8,0x1f38 pid=0x2012,0xf296,0x19 index=5,0,2

0763:2012 Fast Track Pro = 5
04d8:f296 INSTRUMENT1 = 0
1f38:0019 QuNexus = 2


for vid and pid remove all leading zeroes and always add a leading 0x

I placed the FTP first in order even though it is assigned to HW:5 because it has the device_setup option... if any other card is first in order... it would grab that switch instead of the FTP
enable is not required

after running
modprobe -r snd-usb-audio
modprobe snd-usb-audio


cat /proc/asound/cards
returns

Code: Select all

 
 0 [INSTRUMENT1    ]: USB-Audio - INSTRUMENT1
                      Artiphon INSTRUMENT1 at usb-0000:00:1a.0-1.1, full speed
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7c00000 irq 29
 2 [QuNexus        ]: USB-Audio - QuNexus
                      KESUMO, LLC QuNexus at usb-0000:00:1a.0-1.2, full speed
 4 [Loopback       ]: Loopback - Loopback
                      Loopback 1
 5 [Pro            ]: USB-Audio - FastTrack Pro
                      M-Audio FastTrack Pro at usb-0000:00:1d.0-1.4, full speed
The other added benefit of this configuration is if any of these devices are disconnected or off at boot it will not affect their respective HW assignment. If INSTRUMENT1 is off, no other card will grab HW:0. The important element to note is that every audio card, even ones not listed should also be included in the setup/configuration to avoid arbitrary assignment, hence why Intel is assigned to 1 and aloop to 4.