Sorting out sound

I use various bits of USB-connected audio gear for different things. At the moment, I have my Novation Xiosynth 25 and a Behringer UCA-202 audio interface hooked up to my PC, and both work very well. There is, however, a problem. When the machine boots, it's a race to see who gets detected first. Generally the UCA-202 is detected before the Xiosynth, but not always. This means that the ALSA ports can get screwed up on maybe one boot in every four, because they come up in the wrong order. Oops.

We can fake this by plugging in the devices in a certain order. So, Xiosynth first, and we get

[gordonjcp@proto ~]$ aplay -l
* List of PLAYBACK Hardware Devices 
card 0: Intel [HDA Intel], device 0: ALC260 Analog [ALC260 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Xio [Xio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: default [USB Audio CODEC ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
But if I plug in the UCA-202 a little too quickly I get
[gordonjcp@proto ~]$ aplay -l
* List of PLAYBACK Hardware Devices 
card 0: Intel [HDA Intel], device 0: ALC260 Analog [ALC260 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: default [USB Audio CODEC ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Xio [Xio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Okay, how can I solve this? The ALSA wiki holds the clue. We can pass a list of USB VIDs and PIDs to the snd-usb-audio module, and set the index for each device. So, first we need to find out the VID and PID of each device.

[gordonjcp@proto ~]$ lsusb
Bus 005 Device 014: ID 1235:0007 Novation EMS 
Bus 005 Device 013: ID 08bb:2902 Texas Instruments Japan PCM2902 Audio Codec
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 041e:3f07 Creative Technology, Ltd 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
There's also a USB MIDI cable there too, which I want to take care of. I haven't added my Plantronics USB headset, but I could at a later date.

Now you'll need to find modprobe.conf which in my case is /etc/modprobe.d/modprobe.conf - this is where we set the parameters to be passed to the modules. To modprobe.conf I will add the following:

options snd-hda-intel index=0
options snd-usb-audio index=1,2,3 vid=0x1235,0x08bb,0x041e pid=0x0007,0x2902,0x3f07
Now in this case, the on-board Intel HDA sound should be loaded as the first device, with the Xiosynth next, the UCA-202 after it and finally the MIDI cable. Reload the snd-usb-audio module:
[gordonjcp@proto ~]$ sudo rmmod snd_usb_audio && sudo modprobe snd_usb_audio
Now when I plug in just the UCA-202 I should get:
[gordonjcp@proto ~]$ aplay -l
* List of PLAYBACK Hardware Devices *
card 0: Intel [HDA Intel], device 0: ALC260 Analog [ALC260 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: default [USB Audio CODEC ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Success! You'll notice that it shows up as card 2, with no card 1 because the Xiosynth isn't plugged in. When I do plug it in, I get it showing up as card 1. Just to prove the point about MIDI, I can list that too:
[gordonjcp@proto ~]$ amidi -l
Dir Device    Name
IO  hw:1,0,0  Xio MIDI 1
IO  hw:3,0,0  E-MU XMidi1X1 MIDI 1
There's no card 2 because the UCA-202 doesn't have a MIDI port. Now whatever order the devices are detected in, they come up in the right order.

Now, if only there was some way to start alsa_in and alsa_out if I'm running jack when I plug in an audio device. Ah, but we have udev for that...

Posted by gordonjcp on October 7, 2010

Comments

Comments are closed

To prevent spam, comments are no longer allowed after sixty days.