Tuesday, June 19, 2007

Ubuntu: Enabling USB audio

The other day, I managed to break my speaker jack plug and get one piece of it stuck in the soundcard's speaker output, thus rendering it useless. My efforts to get this piece out of there led nowhere, so I started thinking of other alternatives and I ended up getting a USB external soundcard.

The cheapest one I could find was this and there was no way that I would look for anything more expensive as there was the risk that it wouldn't work under linux. However the fact that the device supports MacOS-X was an encouraging fact towards portability. A quick research on the internet also revealed that (at least theoretically) all USB audio devices should work fine as they all use the USB protocol, so no special drivers are required.

Indeed enabling USB audio was very straightforward:

  1. I first opened the Sound Preferences (System→Preferences→Sound) and I selected 'USB Audio' where it was available.
  2. Then I double click on the speaker icon on the top right corner, which brings up the Volume Control window, I muted out all tracks for my old sound device and I closed this window.
  3. Finally, I right-clicked on the icon mentioned above, and I selected Preferences. Then I set the device that this icon controls to 'USB Audio', so that mouse scrolling over this icon will control the volume of the USB audio device.

This whole process was enough to get audio playback to work, but getting sound to work while playing movies required a little bit of additional effort. I actually had to manually change the output device on all video players. Here are the steps required for each one of them.

totem-gstreamer
The configuration for totem-gstreamer is handled by a utility called gstreamer-properties. On the Audio< tab, I set the plugin to 'ALSA' and the device to 'USB Audio'.

VLC player
Go to Settings → Preferences → Audio → Output Modules → ALSA and select USB audio: USB audio (hw:1,0) as the device name. Hitting the Refresh button might be required for this option to appear.
This whole process is important because it reveals to us the actual name for the USB audio device (hw:1,0).

mplayer
Preferences → Audio → ALSA → Configure driver
and set the Device to 'hw=1,0'.

xine
First we need to enable advanced configuration options:
Settings → Setup → GUI Configuration Experience Level
and set it to 'Master of the Universe'.
Then, in order to specify the output device, select the Audio tab and set 'hw=1,0' as the value for the fields Device used for mono/stereo... output.

The only thing I still haven't got to work is the Fn+↑ and Fn+↓ combinations, which really bothers me, since this was the main method I used to control the volume.

Update 1:
Actually these combinations suddenly started working, but I can't remember doing something that I hadn't tried before... I believe the important part is to have the correct device selected in the "Select the device and tracks to control with the keyboard" field under the Sound Preferences window, but as it can be seen in the first screenshot, I had the correct option selected right from the beginning.

Update 2:
Another problem that I forgot to mention in the main article, was that I didn't have sound in Flash, which meant that I couldn't use YouTube and all other video sites. I had tried to solve this problem quite a few times before, but I only succeeded today. The only thing I did was to check that the correct device is selected in gstreamer-properties (which I am not absolutely sure if it plays a role after all) and just re-install the Flash plugin.

2 comments:

Anonymous said...

Another way to list the devices apart from using VLC as described above is in the Terminal:

ben@kuroi:~$ cat /proc/asound/cards
0 [SB ]: HDA-Intel - HDA ATI SB
HDA ATI SB at 0xfe024000 irq 16
1 [HDMI ]: HDA-Intel - HDA ATI HDMI
HDA ATI HDMI at 0xfdffc000 irq 19
2 [SoundSticks ]: USB-Audio - SoundSticks
harman/kardon SoundSticks at usb-0000:00:13.0-1, full speed


so for the SoundSticks I used hw=2,0 in MPlayer.

Maleah said...

Good post.