Multiple Sound Cards/Hardware Devices
Many people here seem to be under the impression that Ubuntu does not support more than one sound card and that having more than one sound card will create insoluble difficulties. This is not true. Setting up for multiple sound cards/devices takes little time and a little understanding about how to do it, that's all. You can have your multiple sound devices up and running in 10 minutes or less by following these directions. If you have any usb devices this will help you.
If your sound card is listed in System/Preferences/Sound, you can make use of it. You can use as many sound cards as you can fit in or on your computer. You can use them separately, or combine them into a number of useful configurations. Many semi-solutions have been available with ALSA for quite a while but this generally involves skillful editing of the asoundrc file and does not address the problematic issue of synchronization of sound device clocks. A gradual drift in clock timing makes these ALSA solutions only partly successful. There are some high end professional audio cards like the Hammersmith and M-Audio line that have provisions for clock timing synchronization, but they are far beyond the needs and pocketbooks of most users. This is about setting up your system so controlling multiple sound devices is easy and convenient.
Assigning Default Devices
A common problem that arises with multiple pci sound cards/devices is that they are not always assigned the same device number on each boot. This can result in an undesirable change in the default ALSA sound device. In order to remedy this problem we can explicitly assign the default device numbers of our sound card drivers by adding lines at the end of the /etc/modprode.d/alsa-base file like this (These are mine):
This way each device will always be numbered the same.
options snd_hda_intel index=0
options snd_cmipci index=1
options snd_atiixp index=2
options snd_usb_audio index=3
You can use:
to discover your sound device driver module names and their order. The code is the the driver names, not the sound card names so be sure to use the driver names or you will get errors when ALSA starts up. You can change the order around as you desire. There is more on assigning cards here
For multiple usb devices
Changing Your Default Sound Card
The biggest problem with multiple sound cards seems to be that many people do not know how to direct their applications to use one or the other.
If you are using just ALSA the easiest way to choose between multiple sound cards is to get:
This little application can be found in System/Preferences as Default Sound Card. Open it and choose your default sound card. All your applications going through ALSA will now use this card. But, to use your other sound card, you must change the default again and this will effect all your applications and they must be restarted for the changes to take place.
If you are using PulseAudio, you can choose pulseaudio in Default Sound Card and use the PulseAudio Volume Control to direct your application to whichever sound card you want to use while they are playing and without restarting them.
Using Multiple Sound Cards with PulseAudio
If you still have bad feelings about PulseAudio, it is due more to an incomplete implementation in the default Ubuntu installation than the Pulse Audio program itself or its developers. If you would like to get PulseAudio working properly and have all your applications use it so you can use more than one sound card more effectively, you can follow my guides here:
If you need more extensive help you can go here
If you do not have your sound set up so all your applications play through PulseAudio and have applications that bypass PulseAudio or are using OSS4, then the following will not necessarily give you positive results. If you are using jackd, there is some information in the second guide above that may also be helpful to understanding this issue.
PulseAudio will automatically detect and make available any sound card which ALSA can find and has a driver for. Unfortunately, PulseAudio is currently unable to detect secondary audio devices that ALSA does not detect as Device 0. This includes digital outputs, secondary dacs, and sound devices incorporated into some newer video cards. These can still be controlled from the ALSA mixers but PulseAudio is unable to detect and use them at this time. This has been fixed in Pulseaudio 0.0.15 which is unfortunately not available for Ubuntu users yet. But there is a way to add support in Pulseaudio for these devices manually. Directions for doing so are here
Controlling Playback and Devices with Multiple Sound Cards
The PulseAudio Volume Control will list all the the devices it can detect in the Output Devices tab. It will also list all applications that are currently using the Pulse Audio sound server in the Playback window. You can right click on any application in that window and choose Move Stream to move it to another device. It is that simple. You can also control the volume of both individual playback streams and the output devices by moving the sliders. You can select any listed output device as the default by right clicking on it.
Another way to control the volume of any device you are using is to select it with the Volume Control applet on your panel. You can use your mixer directly or you can select the mixer in the Volume Control by right clicking and choosing Open Volume Control/File/Change Device. This will allow you to choose and control any hardware or virtual device. To use your multimedia keys for control you need to select the device in System/Preferences/Sound/Default Mixer Tracks.
In the PA Device Chooser/Configure Local Sound Server/Simultaneous Output there is a check box for Simultaneous Output to all local sound cards. If you select it this will add a new Output Device in the PA Volume Control listings
Simultaneous output to ALSA PCM.......(all your sound hardware devices).......
You can select this device in the PA Volume Control just like any other and it will direct streams to all your sound devices simultaneously so you can have sound in your speakers and usb headset etc at the same time.
Combining Sound Cards
PulseAudio also has provisions for making and using more versatile virtual devices like module-combine and module-oss-mmap.To use these, we must edit the etc/pulse/default.pa file to call the modules.
This is how you can manually create a virtual device that will allow you to output to two sound cards at the same time using module-oss-mmap and module-combine:
Open etc/pulse/default.pa in an editor as sudo.
At the end of the file, add these lines
sudo gedit /etc/pulse/default.pa
You can have more than one slave sink attached to the combined sink, and hence combine any number of sound cards.
load-module module-oss-mmap device="/dev/dsp" sink_name=output0
load-module module-oss-mmap device="/dev/dsp1" sink_name=output1
load-module module-combine sink_name=combined master=output0 slaves=output1
Using Multiple Sound Cards for Surround Sound
You can also use multiple sound cards for surround sound by combining them and remapping the outputs.
The channel mappings for the sinks must be explicit to make sure everything is routed correctly. Once again, you can use any number of cards as slaves, explicitly mapping their outputs. module-oss-mmap can also be used to remap the outputs of a single sound card.
load-module module-oss-mmap device="/dev/dsp" sink_name=output0 channel_map=left,right channels=2
load-module module-oss-mmap device="/dev/dsp1" sink_name=output1 channel_map=rear-left,rear-right channels=2
load-module module-combine sink_name=combined master=output0 slaves=output1 channel_map=left,right,rear-left,rear-right channels=4
If you have any questions or problems or additions or comments, please feel free to post here.
EDIT: 02/22/09 Major edit