I’ve just tried adding a USB soundcard to one of my UPnP renderers.
Before plugging it in I did “aplay -L” to record what was there:
<code>
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
</code>
While playing a song via UPnP and gmrender throug the built in 3.5mm jack I plugged the sound card in to one of the USB sockets. The music immediately stopped and for some reason my PuTTY session disconnected - seems that the Pi rebooted (by looking at “uptime”). Once reconnected, I now get:
<code>null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
default:CARD=Device
Generic USB Audio Device, USB Audio
Default Audio Device
sysdefault:CARD=Device
Generic USB Audio Device, USB Audio
Default Audio Device
front:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
Front speakers
surround40:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
Generic USB Audio Device, USB Audio
IEC958 (S/PDIF) Digital Audio Output</code>
So the ALSA “default” and “sysdefault” (what’s the difference?!) are both now pointing to the USB device.
<code>$ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0d8c:000e C-Media Electronics, Inc. Audio Adapter (Planet UP-100, Genius G-Talk)</code>
I set the music to play again via my phone and plugged the audio jack into the green socket of the sound card but I still did not hear any music. Perhaps the volume is low? The command line “amixer” command is still reporting that there is only mono output so I don’t think it is reliable. The “alsamixer” command gets us somewhere though: it starts up showing the full volume for the built in audio output but pressing F6 lets me choose the new USB soundcard and set the volume to max. Still no sound though…
<code>$ lsmod|grep snd
snd_bcm2835 16304 4
snd_usb_audio 104097 0
snd_pcm 77560 3 snd_bcm2835,snd_usb_audio
snd_page_alloc 5145 1 snd_pcm
snd_hwdep 5929 1 snd_usb_audio
snd_usbmidi_lib 18067 1 snd_usb_audio
snd_seq_midi 4591 0
snd_seq_midi_event 6544 1 snd_seq_midi
snd_rawmidi 21160 2 snd_usbmidi_lib,snd_seq_midi
snd_seq 53329 2 snd_seq_midi_event,snd_seq_midi
snd_timer 19998 2 snd_pcm,snd_seq
snd_seq_device 6438 3 snd_seq,snd_rawmidi,snd_seq_midi
snd 58447 16 snd_bcm2835,snd_usb_audio,snd_hwdep,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_usbmidi_lib,snd_seq_device
</code>
<code>$ cat /proc/asound/cards
0 [ALSA ]: BRCM bcm2835 ALSbcm2835 ALSA - bcm2835 ALSA
bcm2835 ALSA1 [Device ]: USB-Audio - Generic USB Audio Device
Generic USB Audio Device at usb-bcm2708_usb-1.3, full speed
</code>
Then export “ALSA_PCM_CARD=Device” sets the default card to the USB sound card.
Testing with sounds in ”/usr/share/scratch/Media/Sounds”.
<code> $ sudo apt-get install mpg123
aplay *.wav
mpg123 *.mp3 </code>
Both of these coming out of USB sound card now, but gstreamer still using the built-in device. Ssound quality from USB is not very good…
$ gst-launch filesrc location=Garden.mp3 ! mad ! alsasink
That uses gstreamer to send an mp3 to ALSA and it comes out of the USB card. Sounds just the same (not good) as the mpg123 command.
Comments
Comments powered by Disqus