While I was working on a new project (an Internet Radio and Airplay server) with my Raspberry Pi I ran into an interesting sound issue. My original development on the project was done using the built in audio from the headphone jack and all was great except that the Raspberry Pi doesn’t produce the best quality analog audio. I wanted something better so I ordered a Ti PCM2704 USB DAC card. The card was very cheap but should produce better sound than I was getting from the Raspberry Pi’s headphone jack. My new DAC card arrived and I plugged it into my project.
The Default Audio Device
The first thing that I noticed is that all my audio was still coming out of the Raspberry Pi’s headphone jack. A but of searching on the net and a quick fix was discovered. I just needed to change the order (index) that ALSA used to disover and list the sound cards. you can check this by using the aplay command to list your sound devices. Card 0 will be your default card and mine was still pointing to the Raspberry’s bcm2835 device.
# aplay -l
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
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: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
options snd-usb-audio index=-2
options snd-usb-audio nrpacks=1
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
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
Sharing the Sound Device
pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave