For example, on my system, I getĬard 0: Intel, device 0: CONEXANT Analog Ĭard 0: Intel, device 1: Conexant Digital Ĭard 1: TuxDroid, device 0: USB Audio Ĭard 1: TuxDroid, device 1: USB Audio Ĭard 2: Headset, device 0: USB Audio You can get a list of sound cards (with some extra information) with aplay -l. Example 2: start Firefox as ALSA_CARD=Headset firefox to have the sound Flash movies played on the card named Headset. Example 1: ALSA_CARD=Headset mplayer -ao alsa file1.mp3. If you have multiple sound cards (possibly the sound card in your computer, and an external USB headset), you can set the environment variable ALSA_CARD to direct playback to a specific card. After that, mplayer -ao alsa file1.mp3 should start the first playback, and simultaneously, mplayer -ao alsa file2.mp3 should start the second playback. This includes the web browser (with flash), pulse, esd, artsd, mplayer, Skype, MPD and system sounds (disable everything in Gnome / System / Preferences / Sound / Sound). If even the first mplayer produces the Device or resource busy error, then close or kill all applications that might play sound.
(Please note that you can omit =-ao alsa= from the mplayer command line if you add ao=alsa to your ~/.mplayer/config file.) If the second mplayer doesn't start playback, but exists with an error message containing Device or resource busy, this means there is something wrong with your settings – this tutorial will help to fix that. You should hear both playbacks at the same time. So you just run mplayer -ao alsa file1.mp3, and simultaneously (possibly in another terminal window) mplayer -ao alsa file2.mp3. ALSA, by default, enables dmix for all cards which don't support concurrent playback of more than one sound stream. The dmix feature of ALSA does software sound mixing, so it makes it possible to run multiple playbacks simultaneously on the same card. Let's suppose you have a Linux system and many sound cards with an ALSA (>= 0.9) driver, and you don't use any sound server (e.g. To apply this setting for all users, add the lines above to /etc/nf instead.) If this doesn't work for you, please continue reading. Get the list of available sound cards with aplay -l | awk '/^card/'|sort|uniq. (Replace Headset with the name of the card on which you want to hear sound. The quick trick is having defaults.pcm.!card Headsetĭefaults.ctl.!device 0 in your ~/.asoundrc.
This blog post is tutorial which describes how to select a default sound card and run multiple playbacks simultaneously, using ALSA on Linux, without a sound server.