====== Mixed Sound with ARTS and ALSA ====== This is how I set up my desktop system to play sounds from various applications simultanously. Namely these applications are XMMS, GAIM, MPlayer and Firefox (with Flashplugin). All working on my Intel onboard soundcard: From ''/proc/pci'': Bus 0, device 31, function 5: Multimedia audio controller: Intel Corp. 82801DB (ICH4) AC'97 Audio Controller (rev 2). IRQ 9. I/O at 0xa800 [0xa8ff]. I/O at 0xa400 [0xa43f]. Non-prefetchable 32 bit memory at 0xe4000000 [0xe40001ff]. Non-prefetchable 32 bit memory at 0xe3800000 [0xe38000ff]. ===== Kernel ===== I use the new [[Kernel2.6|2.6 Kernel]] on my Desktop System which comes with Alsa. Compiling is straight forward here are the options I used for the soundcard (only selected ones shown): Device Drivers ---> Sound ---> <*> Sound card support Advanced Linux Sound Architecture ---> Advanced Linux Sound Architecture Sequencer support Sequencer dummy client OSS Mixer API OSS PCM (digital audio) API [*] OSS Sequencer API RTC Timer support Generic devices ---> Virtual MIDI soundcard Generic MPU-401 UART driver PCI devices ---> Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111 I load the modules in my ''/etc/modules'' file: snd-intel8x0 snd-pcm-oss snd-seq-oss ===== .asoundrc ===== For using alsa you should install some tools, too. #> apt-get install alsa-utils alsa-oss ALSA comes with a method to mix multiple sound streams which is called //dmix//. ALSA-enabled applications should be able to all access the device at the same time when it is set up. Do this you'll need to set up an ''.asoundrc'' file in your home directory. I followed the descriptions at http://alsa.opensrc.org/index.php?page=asym to do so. This is what my .asoundrc looks like: #asym fun start here. we define one pcm device called "dmixed" pcm.dmixed { ipc_key 1025 type dmix slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 rate 48000 } } #one called "dsnooped" for capturing pcm.dsnooped { ipc_key 1026 type dsnoop slave.pcm "hw:0,0" } #and this is the real magic pcm.asymed { type asym playback.pcm "dmixed" capture.pcm "dsnooped" } #a quick plug plugin for above device to do the converting magic. saves #typing when settng the pcm name in an alsa app pcm.pasymed { type plug slave.pcm "asymed" } #a ctl device to keep xmms happy ctl.pasymed { type hw card 0 } #here we try to point the aoss script to our asymed device pcm.dsp0 { type plug slave.pcm "asymed" } ctl.mixer0 { type hw card 0 } #this sets the default device pcm.!default { type plug slave.pcm "asymed" } It's pretty much the same as decribed in the given link. However I did not work very reliable for me. XMMS with using the ALSA output plugin did play a half song fine but then suddenly stopped playing without reason. Another problem was getting applications to work with it which doesn't support ALSA. The documents say to use a library wrapper called ''aoss''. This tool maps OSS system calls to the ''dsp0'' device to the ''asymed'' ALSA device. This did work for mpg321 but not for Firefox which simply froze when playing a flash with sound. ===== ARTS ===== The solution to the above mentioned problems is to use a sound daemon. the only one I found working as expected is ARTS. #> apt-get install arts To give it the needed permission for realtime scheduling make it's startwrapper SUID root: #> dpkg-statoverride --add --update root root 4755 /usr/bin/artswrapper Arts needs to be started on login. Either do it from your ''~/.xsession'' file or (if you using a standards compatible desktop environment like XFCE) put a symlink in your Autostart directory: $> mkdir -p ~/Desktop/Autostart $> ln -s /usr/bin/artswrapper ~/Desktop/Autostart/artswrapper ===== Application Setup ===== ==== Firefox ==== To make firefox use the ARTS daemon we use a library wrapper similar to the above mentioned ''aoss'' the only difference is it works ;-) It's called ''artsdsp'' - so for running Firefox with ARTS just run the following command from the Firefox directory. $> artsdsp ./firefox To be sure it works install the Flash Plugin and try my silly animation at http://splitbrain.org/Study/Media_Creation/index.php - if you don't hear sound then something is wrong. Note: If you're using a debian package of Firefox you can set the soundwrapper in ''/etc/firefox/firefoxrc'' like this: # which /dev/dsp wrapper to use FIREFOX_DSP="artsdsp" ==== XMMS ==== Easy - just install the plugin: #> apt-get install xmms-arts ==== GAIM ==== More easy - go to the preferences and select ''Arts'' at the ''Sound Method'' dropdown. ==== MPlayer ==== Well the [[http://mplayerhq.hu/DOCS/HTML/en/devices.html#audio-dev|documentation]] says there is an ''arts'' driver however my MPlayer doesn't have it (I us a precompiled Debian package from [[unofficialdebs|Marillat]]). ''mplayer -ao help'' gave me the follwing options: Available audio output drivers: mpegpes Mpeg-PES audio output oss OSS/ioctl audio output alsa9 ALSA-0.9.x audio output esd EsounD audio output sdl SDLlib audio output null Null audio output pcm RAW PCM/WAVE file writer audio output plugin Plugin audio output Now the dmix feature configured above comes in handy again. We just use the ''asymed'' device which is able to mix multiple sources. So it's possible to have both - ARTS with multiple Soundsources __and__ MPlayer - accessing the same ALSA device. Just add this to the ''~/.mplayer/config'' ao=alsa9:asymed #or ao=alsa1x ... srate=48000