Selecting audio output devices in ALSA

I’m beginning to appreciate how much Ubuntu does out of the box more and more as I find more little things in Crunchbang that require a non-trivial amount of internet scouring and trial/error to figure out. Ubuntu by default uses pulseaudio as the Linux soundserver, and Ubuntu provides a pretty GUI for switching between output audio devices. Crunchbang uses ALSA by default, and switching audio devices is slightly more difficult.

The default output device is set through the ~/.asoundrc file. You list the devices typing “aplay -L” in terminal. The output looks something like this:

I switch devices by commenting and uncommenting out the relevant lines for selecting what device I want. Switching a default device by configuration file requires restarting the process that uses sound. For playing Youtube videos in your browser, this means restarting the browser whenever you switch an audio device. (There might be a better way to do this, I haven’t figured it out yet.)

The above method works for all processes that require sound that are started by me. However, I also use mpd/mpc as my music player, which is a background service that doesn’t consult ~/.asoundrc for sound settings. Output devices are specified in /etc/mpd.conf. The syntax for setting an output device in mpd.conf is “device “hw:x,y”, where x is the sound card and y is the output device. This is slightly different from the information you provide for ~/.asoundrc; you get this information from “aplay -l” (note the lower case L). The output of “aplay -l” looks like this:

Again, I comment and uncomment the device lines to switch audio devices. Switching audio devices for mpd requires a service restart, just like for the processes that consult ~/.asoundrc, which I do with “sudo service mpd restart”.

These links were useful in helping me figure out what settings to use: