ALSA/Software_dmix_Configurations
Contents |
Software dmix Configurations
Configuring aRts and KDE
aRts Approach
aRts is a framework for developing modular multimedia applications. The sound server, artsd, allows multiple applications to cooperatively process and output sound and music. aRts is designed to provide its filter and synthesis capabilities to other applications using the multimedia communication protocol (MCOP). aRts is also capable of modular realtime synthesis. It can create sounds & music (realtime midi synthesis) using small modules like oscillators for creating waveforms, various filters, mixers, faders, etc.
Redirect aRts to your dmix device for best performance. This can be done by overriding the device location to plug:dmix.
ALSA Approach
This is the preferred solution since there is no need for another layer below that.
Can be used with KDE 3.2.2 and above by redirecting aRts to your ALSA (dmix) device. Versions 3.2.1 and below require OSS emulation.
OSS Emulation Approach
This is only necessary for KDE versions 3.2.1 and below since those do not yet recognize ALSA. Using this in versions subsequent to that will cause degraded performance.
- Setup OSS Emulation as directed earlier in this article.
- In KDE Control Center, chose Open Sound System as your default sound server. If necessary, you can check Override Device Location and enter a /dev/dsp device corresponding to your configured sound card.
Configuring Gnome/eSound
Recent releases of esound support alsa plug in hw devices, so if your gnome apps, or some binary apps, could easily work with esound, and you don't care about latency, esound can play out to dmix, which works nicely.
Make sure that your esd uses alsa, and add -d default option to /etc/esd/esd.conf.
| File: /etc/esd/esd.conf |
[esd] auto_spawn=1 spawn_options=-terminate -nobeeps -as 2 -d default spawn_wait_ms=100 |
If you notice that esd doesn't want to play through default device, or if you launch esd -d default, it segfaults, it means that you have esound<=0.2.32, which use obsolete alsa API. If it's true, install more recent, or compile latest esound with esound-alsa-pcm-newapi.patch
pulseaudio
Edit /etc/pulseaudio/defaults.pa, so that all lines containing module-alsa-sink also contain device=dmix (dmix, or whatever the mixing device in your /etc/asound.conf is). Example config file:
| File: /etc/pulseaudio/defaults.pa |
#!/usr/bin/pulseaudio -nF # # This file is part of pulseaudio. # # pulseaudio is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # pulseaudio is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with pulseaudio; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # Load audio drivers statically #load-module module-alsa-sink sink device=dmix #load-module module-alsa-source device=plughw:1,0 #load-module module-oss device="/dev/dsp" sink_name=output source_name=input #load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input load-module module-null-sink #load-module module-pipe-sink # Load audio drivers automatically on access # ALSA add-autoload-sink output module-alsa-sink sink_name=output device=dmix add-autoload-source input module-alsa-source source_name=input # OSS add-autoload-sink output module-oss device="/dev/dsp" sink_name=output source_name=input add-autoload-source input module-oss device="/dev/dsp" source_name=input sink_name=output #add-autoload-sink output module-oss-mmap device="/dev/dsp" sink_name=output source_name=input #add-autoload-source input module-oss-mmap device="/dev/dsp" sink_name=output source_name=input # Load several protocols load-module module-esound-protocol-unix #load-module module-esound-protocol-tcp load-module module-native-protocol-unix #load-module module-simple-protocol-tcp #load-module module-cli-protocol-unix # Load the CLI module load-module module-cli # Make some devices default set-default-sink output set-default-source input .nofail # Load something to the sample cache load-sample x11-bell /usr/share/sounds/generic.wav #load-sample-dir-lazy /usr/share/sounds/*.wav # Load X11 bell module load-module module-x11-bell sample=x11-bell sink=output # Publish connection data in the X11 root window load-module module-x11-publish #load-module module-pipe-source #load-module module-pipe-sink |
jack
Alsa and oss applications can work with jack. The following will work with sound cards with hardware mixing capability (for example soundblaster live and audigy). Edit /etc/asound.conf and add the following
| File: /etc/asound.conf |
# convert alsa API over jack API
# use it with
# % aplay foo.wav
# use this as default
pcm.!default {
type plug
slave { pcm "jack" }
}
# pcm type jack
pcm.jack {
type jack
playback_ports {
0 alsa_pcm:playback_1
1 alsa_pcm:playback_2
}
capture_ports {
0 alsa_pcm:capture_1
1 alsa_pcm:capture_2
}
}
|
This will work with most alsa applications. Some applications will not work, for example beast with the alsa plugin. When starting an alsa application as usual, if jackd is started, the application will use by default the jack plugin and appear in the connection panel of qjackctl. Otherwise, it will generate an error message and start using alsa.
OSS emulation and jack
Edit /etc/asound.conf and add the text in the preceding text box (alsa and jack) as well as the following:
| File: /etc/asound.conf |
# oss will use the alsa to jack API by default # test it with # % aoss mpg123 some.mp3 pcm.dsp pcm.!default |
It will work the same as the alsa to jack converter. Some applications will not work, for example beast.
Note
mplayer will crash with this setting when jackd is started. To avoid it, start mplayer with native jack driver:
# mplayer -ao jack movie.avi
SPDIF
Example of ~/.asoundrc to enable Dolby Digital Out
| File: .asoundrc |
pcm.!default spdif |
XMMS
XMMS has been removed from Portage because it is unmaintained upstream - the closest replacement is probably audacious.
Options -> Preferences -> Audio
- Select Alsa Plugin
- Output Plugins Preferences
- Audio Device: "dmixer" (per example conf above) which is the same as "ossmix". If dmixer doesn't work with your version of the ALSA output plugin, try to specify plug:dmixer as the output device. If dmixer doesn't work, use dmix.
- Use software volume control
- Advanced Settings (these settings may be for a particular sound card)
- buffer time: 750ms
- period time: 75ms
- uncheck mmap mode, if present
Pidgin
Tools->Preferences->Sounds->Sound Command: aplay %s
Firefox, Mozilla, RealPlayer, Skype & Co
I, like many before me, fought for quite a while with getting Firefox to function properly.. I'm striking through the example below that was solely for Firefox, because it's no longer needed, and I hope someone with more knowledge of the Wiki's format will clean this up behind me.. (I didn't strike out the other things)
Firefox will use your ARTs system, using aoss, without the need to edit ANY of Firefox's files.. I can't believe it took me a week to figure that out.. =P You do, however, need to do one thing:
# emerge -av media-libs/alsa-oss
To make its plugins (especially libflashplayer.so) use dmix through aoss:
- Move the original firefox symlink
# rm /usr/bin/firefox # ln -s /usr/libexec/mozilla-launcher /usr/libexec/firefox
- Create a new executable script:
| File: /usr/bin/firefox |
#!/bin/sh # This line needs to be maintained or Thunderbird (and # certain other apps) will not launch links when they # are clicked on export MOZILLA_LAUNCHER=firefox # not correct: #aoss /usr/libexec/firefox $* # # correct: aoss /usr/libexec/firefox "$@" |
- From my experience with Firefox 1.5.x (source, not bin), you don't need to do that stuff above, just edit last line of /usr/bin/firefox - insert aoss after exec
# exec aoss /usr/libexec/mozilla-launcher "$@"
- Alternatively to all above, you can simply edit /usr/libexec/mozilla-launcher to care take of mozilla, firefox, and seamonkey all at once. Around line 400
| File: /usr/libexec/mozilla-launcher |
else
#"$mozbin" "$@" & #old line
aoss "$mozbin" "$@" & #new dmixed line
fi
|
The above is not necessary because /usr/libexec/mozilla-launcher (from www-client/mozilla-launcher-1.56) (lines 449, 457 and 460) already include $(type -P aoss), which will evaluate to aoss if aoss is installed and nothing otherwise. In a similar fashion it is also possible to "dmix" other oss apps like:
- gflashplayer
- realplayer
- skype (note: it doesn't fully work though. See here)
- mozilla (suite)
This way one can have, say, several tabs with flash all sounding together and receive an incoming call or system sounds.
For example:
# rm /usr/bin/skype # touch /usr/bin/skype # chmod +x /usr/bin/skype
and its contents:
| File: /usr/bin/skype |
#!/bin/sh aoss /opt/skype/skype "$@" |
Even more - if You do this wisely, there is no need to edit any menus or preferences (like "default browser").
LICQ
Set to use aplay in preferences.
SDL
Set environment with:
| File: /etc/env.d/99sdl |
SDL_AUDIODRIVER=alsa AUDIODEV=default |
GStreamer
Emerge gnome-media, then run gstreamer-properties and set your Audio-Sink. Output is Custom. Pipeline is alsasink -device=dmix (or device=ossmixer, if that's what you used in your asoundrc, or simply -device=dmix if you didn't edit it)
(Hint: rhythmbox uses gstreamer)
GStreamer in many ways handles ALSA badly. For example, with a dmix channel configured to output 48khz, GStreamer will natively play audio through this device at 48khz, but using (commonly) 44.1khz data. Without resampling, the audio will sound highly distorted.
The solution is to create a custom output pipeline incorporating explicit resampling to the desired format in gstreamer-properties:
audioconvert ! audioresample ! audio/x-raw-int, channels=2,depth=16,rate=48000 ! alsasink -device=channel0
Note that this solution is quite CPU intensive compared to functionaly similar software, such as the crossfade plugin.
MPD
audio_output {
type "alsa"
name "Sound Card"
options "dev=dmixer"
device "plug:dmix"
}
Xine Engine
Add this line to your xine config file:
| File: ~/.xine/config |
audio.driver:alsa |
Be sure to remove or comment out all other "audio.driver:" lines in the file. Alternatively if you have xine-ui, run xine, right click the main windows and select Settings->Setup->audio
Set "audio driver to use" to alsa.
Amarok
aRts engine is deprecated and removed from newer versions of Amarok, as is GStreamer. Xine is the default output engine now.
Only necessary If arts is not working well with dmix. There are two possible solutions. Both require to change the engine used in amarok.
Settings->Configure amaroK...->Engine
1. solution: xine engine:
Set "Sound System" to "Xine Engine".
Configure xine to use alsa as shown above.
2. solution: gstreamer engine:
Set "Sound System" to "GStreamer Engine"
Set "Output Plugin" to "alsasink"
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.
