How can I make my ALSA card to use the fixed number?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hi,

I have the USB DAC connected to the Raspberry Pi. In .asoundrc it's defined as card 2, device 0. Sometimes after rebooting the Pi that USB DAC becomes (aplay -l) card 1, device 0 and audio doesn't go through it. Is there any way to make the USB DAC always use the fixed card number e.g. card 2?

Thanks!
 
You can often refer to ALSA devices by name. I will use as an example the soundcards on one of my Linux boxes, listed below:

Code:
charlie@CI327:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: USB [Scarlett 6i6 USB], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 3: Device [USB Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

You can see from the above output of the command "aplay -l" that there are four cards, numbered 0 through 3. Let's say I want to use card 2, the Scarlett 6i6. I need to know the name for the device and mode in which I Want to use it. So I issue the command "aplay -L" and search the output. I will just post the relevant part of that output:
Code:
front:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    Front speakers
surround21:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
    Scarlett 6i6 USB, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers

If I want to use the Scarlett in 2 channel mode, where I would usually write:
Code:
hw:2,0
I write
Code:
front:CARD=USB,DEV=0
or
Code:
hw:CARD=USB,DEV=0


Under ALSA these names for the card never change, even if the card number does. Try it on your system.
 
Last edited:
Thank you CharlieLaub! It worked when I changed the lines in the .asoundrc from:
Code:
...
ctl.!default {
  type hw card 2
}
...
pcm.plugequal {
  type equal;
  slave.pcm "plughw:2,0";
}
...
to

Code:
...
ctl.!default {
  type hw CARD=PCM2702,DEV=0
}
...
pcm.plugequal {
  type equal;
  slave.pcm "plughw:CARD=PCM2702,DEV=0";
}
...
Best regards
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.