In Linux, only one program can play a sound at a time unless you have a soundcard that supports hardware mixing (all/most onboard soundchips don't.) or one of the methods outlined under are being used. All the methods are using some form of software mixing.
* 1 dmix - Alsa's software mixing system.
* 2 ALSA with oss2jack
2.2 More Information
* 3 joss(up until now it has been called q3jack..)
* 4 OSS/Commercial - www.opensound.com (free)
* 5 Use soundcard that supports hardware mixing
* 6 Old or discouraged methods
6.1 aRTS - KDE Project's software mixing
6.2 Polypaudio - http://0pointer.de/lennart/projects/polypaudio/
6.3 NAS http://radscan.com/nas.html
6.4 ESD - http://www.tux.org/~ricdude/EsounD.html
6.5 USound - http://mattcamp.paunix.org/usound/
* 7 Problems and Solutions for certain programs
* 8 Other information
dmix - Alsa's software mixing system.
(dmix reduces the sound quality during mixing and it doesn't work well with some oss apps. You should try hardware mixing or oss2jack first.)
Put the following lines into /etc/asound.conf. note:in most cases this config is no longer needed!
And magically, next time a program tries to use sound, dmix will kick in.
You might find that only one user can use the dmixer at a time. This is probably ok for most but for those like myself who run mpd as a seperate user this poses a problem. When mpd is playing my normal user can't play though the dmixer. While its quite possible to just run mpd under my login account I found another solution. Adding the line ipc_key_add_uid 0 to the pcm.dmixer block disables this locking. The following is a snippet of my asound.conf, the rest is the same as above.
To make most programs use Alsa, make sure /etc/libao.conf only contains the following.
For other programs who insist on their own audio setup, eg, XMMS or Mplayer, you would need to set their specific options.
For mplayer, open up ~/.mplayer/config (or /etc/mplayer/mplayer.conf for global setting) and put the following line in:
For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.
To do this in XMMS:
* Open XMMS
Options -> preferences.
Choose the Alsa output plugin.
For applications which do not provide a ALSA output, you can use aoss. To use aoss, when you run the program, prefix it with aoss(alsa-oss), eg:
If you don't want to have to do that each time, look at examples below.
your running firefox and you want to get sound from your propriatory flash-plugin which only has oss sound output support:
aoss /opt/mozilla/bin/firefox "$@"
same but switfox(NOTE: i made this file myself simply switching the entries. I do NOT know if this startups swiftfox in the way it is intended so beware)
aoss /opt/swiftfox/swiftfox "$@"
Also selfmade so beware as i'm not excactly a script whiz(and 9.0-20060616.6 would probably need to be modified to your version on upgrade ofc):
aoss /usr/lib/opera/9.0-20060616.6/opera "$@"
And remember to make the scripts executable ofc:
chmod +x /usr/bin/fileALSA with oss2jack
UPDATE: Stopped working with ET and Quake3 for some unknown reason... :/ I(nut543, author of oss2jack packages) now recommend to just use the aoss method and the 'snd_pcm_oss' kernel module for games & apps aoss don't support(like ET).
(UPDATE: oss2jack 0.25-6 works perfectly with ET, kernel26beyond 2.6.17.beyond3)
"oss2jack - A Linux kernel based approach to using OSS applications with the Jack Audio Connection Kit"
You might want to remove esd, artsd, polypaudio, etc. too as you won't really be needing them unless an app only has artsd output for example.
To use oss2jack, you will need two packages,oss2jack
You will need to download the tarballs for each package and run makepkg to create the package. 1.
After having installed the packages, put the oss2jack after jack-audio-connection-kit in the DAEMONS array in /etc/rc.conf if you want oss2jack to start automagically on boot.
Edit /etc/conf.d/jack-audio-connection-kit and change the SERVER_PARAMS and DRIVER_PARAMS to suit your needs. I make the entries look like this:
SERVER_PARAMS="-R -s -d alsa"
DRIVER_PARAMS="hw:0 -p 64 -r 44100" #the reason you write "hw:0" is because the "-d" is already specified in /etc/rc.d/jack-audio-connection-kit thus making jackd run like "jackd -R -s -d alsa -d hw:0 -p 64 -r 44100"
If you have a slower computer, you may want to increase the period from 64 to 128 or 256.1 ( 512 or 1024 is just fine, don't waste your CPU)
This can be used as solution to the "teamspeak and mic + ingame sound/music while using xmms" or whatever problem one see all around the net. If you need more info see the oss2jack site (linked below). Notes
* Wine requires the audio to be 'Emulated' (change in winecfg's audio tab)
* If you have MOD_AUTOLOAD="yes" in your rc.conf you might need to have !snd_pcm_oss !snd_seq_oss in your MODULES array to disable autoloading of these modules by udev.
* If you need to start oss2jack as a user(with realtime capabilties), you need to compile and install the realtime-lsm module.
* Some apps/games require the snd-mixer-oss kernel-module loaded(UT2004 for example), this might be(but probably isn't) unstable for the oss2jack daemon. Note that alsamixer will still let you set PCM, MASTER, etc volume regardless of if you have snd-mixer-oss loaded.
* If you have issues setting the OSS volumes, try using audacity to set the volumes. Audacity is available in the Extra repository and is a sound editor that uses OSS. It has controls for input (mic) and output volumes. The voluemes set with Audacity are OSS volumes, not ALSA volumes. You should only use this solution if using an ALSA mixer doesn't work for some reason, as setting the OSS volumes may unintentionally change the ALSA volues due to oss2jack's emulation.
* If you are running other OSS drivers in your kernel, you will have to bind oss2jack to a different device. To bind oss2jack to /dev/dsp2, edit /etc/rc.d/os2jack and change the line:
/usr/bin/oss2jack -n 2 &
If you're using kernel26beyond (patched and optimized for desktop), you can install schedtool and start jackd by schedtool -I -e jackd.... The "-I" option means a special, limited real-time priority policy, which may use only up to 80% of CPU (to prevent your system from freeze)More Informationoss2jack
oss2jack installation instructions
JACK Audio Connection Kit
Errors I encountered
--Read this if you have other problems not mentioned here joss(up until now it has been called q3jack..)
recently a similar solution as the above has come up which doesn't require a kernel module but has other limitations (08-03-2006). update: now the download link works on the site again. Note that it has no capture support as-of-yet (05-09-2006).
I haven't tried it out but here is all i know about it(if you try it out please improve this entry): http://www.linux-gamers.net/modules/newbb/viewtopic.php?topic_id=2075&forum=14
developers(down) site: http://www.konstruktiv.org/q3jack/ OSS/Commercial - www.opensound.com (free)
OSS/Commercial is a commercial sound driver that contains a software mixer in kernel-space, and it's free for personal and non-commecial use. SeeOSS_Commercial_Setup
for more information.Use soundcard that supports hardware mixing
Old SoundBlaster Live series (emu10k1 chip) and new Audigy series (emu10k2 chip) cards are known to work.
The SoundBlaster Live 5.1 is fairly easy to find and is cheap to buy.Note
: new cheap Audigy SE, Audigy 2 NX, SoundBlaster Live 24bit and SoundBlaster Live 7.1 does not support hardware mixing (they use other chips).
99% of motherboards with integrated sound do not support hardware mixing.
The onboard VIA8237 chip supports 4-stream hardware mixing. However it does only 3 for some motherboards (the 4th makes no sound), or just broken. Even if it works, the quality is not good compared to jackd/oss2jack or oss/commercial's. Old or discouraged methods
The following methods are NOT designed for music or games, but short-time audio such as chat notify. They require a lot of CPU resource and have very high latency.aRTS - KDE Project's software mixing
pacman -S arts
Then if you use KDE, aRTS will be started for you automatically. If you don't use KDE and want arts to start whenever you start your computer, add this line to a system startup file such as /etc/rc.local:
/opt/kde/bin/artsd -a oss &
To hear the music, set your program's audio outputs to arts.
For apps that do not provide an aRTS output, you may prefix them with artsdsp, eg:
/opt/kde/bin/artsdsp -m xmms
/opt/kde/bin/artsdsp -m EnemyTerritory <-- although the sound will lagg behind.
If you find you have problems, try different arguments, which can be found by running the commands below.
polypaudio is a less intensive implementation of a sound mixing server than ESD and ARTS but doesn't have fancy 3D sound effects etc like arts. Ubuntu Linux is switching to this server instead of ESD.
Unique features. Check the readme. Has builtin mixing. You may get it to work with libaudioss, therefore nearly audio apps that have an OSS output will work with this, and it will be "lag-free". It does not have mmap support however, and this causes it to not work with many games.
ESD is a dated solution that hasn't been updated for many years, however it has excellent application support and works well for basic desktop usage.
adding 'esd' to the daemons section in rc.conf did the trick for me.
USound is somewhat similar to the Enlightened Sound Daemon (EsounD), but as the name suggests, USound aims to be more useful, particularly for consumer desktop and multimedia applications. At the time of writing (0.2) it has support for libao, mplayer, madplay and Speak Freely
Problems and Solutions for certain programs
for a Skype
* See Gentoo-Wiki referring to dmix
for information on how to set up different programs (firefox, mpd etc.) to use dmix