Linux (bless its little heart) wants to see mass adoption on the average computer user's desktop in the place of a certain product produced by a Redmond company of opposite alignment. However, despite its best intentions, people often avoid it because things hardly ever just work.

Now, sound in Linux has been improving steadily. The ALSA drivers and tools (part of the kernel source itself) support a lot of cards, and generally it isn't that hard to configure (your distro may even compile all supported sound cards as modules and load them appropriately). This is all well and good, until two applications try using the sound card at once...

Hardware & Software Mixing

If you are a very lucky soul, everything will just work, straight off, with no extra configuration needed. The reason for this is that you have a sound card with hardware mixing capabilities supported by ALSA. This means that when two different applications are trying to use the sound card, it will take everything they are throwing at it, and mix them together nicely before sending it to your speakers. If so, great – you can go read something else now. Go on, off with you.

Sadly, most cards don't provide this feature and need a little help. Under Windows this happens automatically, but ALSA does not support it natively. The most common solution is to use what's known as a sound server, such as the arts sound daemon provided by KDE. Unfortunately these programs tend to be bloated, slow, and unsupported by many common applications. Who needs stuff like network support in a mixer, when you just want to dump more than one stream at a sound card?


Dmix is a plugin for ALSA which is included in the standard distribution. Through this you can mix multiple sound streams by sending them to a pseudo-device which performs the required mixing in software before sending the mixed data to the actual sound card device. By configuring it as your default sound device, all programs with ALSA support (practically every sound application under Linux) will use the device automatically. Older programs which use the deprecated OSS will still work, however you will need to launch them via the command aoss, e.g. “aoss realplayer”. Your nasty, slow sound daemon can also be routed through a Dmix device.

To set up Dmix, simply create/add to an asound configuration file. You can do this in the system-wide location, “/etc/asound.conf”, or in a per-user basis such as “~/.asroundrc”. I suggest the latter method, as it makes it easier should you mess anything up. My personal configuration looks like this: (you can probably use this verbatim, and it will work straight off assuming that your sound card is configured as the first card in the system)

pcm.swmix {
        type dmix
        ipc_key 313
        slave {
                pcm "hw:0,0"
                period_time 0
                period_size 1024
                buffer_size 8192
                rate 44100
pcm.dsp0 {
        type plug
        slave.pcm "swmix"
ctl.mixer0 {
        type hw
        card 0
pcm.!default {
        type plug
        slave.pcm "swmix"

Working? Happy? Good stuff. Play MP3s, watch videos, laugh at flash files... all at once, with little latency. Feel pleased. Wallow in your exuberance. You have triumphed against user-unfriendliness.

Useful source: