This page contains configuration stuff for
ALSA under
Debian GNU/Linux, running on an Apple titanium Powerbook G4, using ALSA's
dmix plugin; this useful bit of code provides software mixing
for cards that don't do automatic mixing in hardware, so you can play
several things at once (for instance, have a sound play when your email
arrives, even while you're listening to music).
Thanks to the authors of the DmixPlugin page on alsa.OpenSrc.org.
/etc/asound.conf
pcm.swmix {
type dmix
# any unique number here
ipc_key 313
slave {
pcm "hw:0,0"
# these settings may require tweaking for different sound
# cards; this is for the Powerbook's built-in snd-powermac
# probably not required at all for well-behaved cards...
period_time 0
period_size 1024
buffer_size 8192
# mentioning rate fixes wrong speed/pitch in native ALSA stuff
rate 44100
}
}
# this makes OSS emulation via aoss default to using dmix, allegedly
pcm.dsp0 {
type plug
slave.pcm "swmix"
}
ctl.mixer0 {
type hw
card 0
}
# this makes native ALSA apps default to using dmix
pcm.!default {
type plug
slave.pcm "swmix"
}
/etc/alsa/modutils/0.9 or
/etc/alsa/modutils/1.0
If your distribution's ALSA packages don't handle module loading the
same way Debian does, you should arrange for this to be included in your
/etc/modules.conf somehow.
Also arrange for your sound card's module to be loaded on boot, for
instance by putting snd-powermac (or whatever) in
/etc/modules.
If you want compatibility with the older OSS, you should also arrange
for the snd-mixer-oss, snd-pcm-oss and
snd-seq-oss to be loaded somehow; put them in
/etc/modules, or modprobe them in an init script,
or something similar.
(On Debian, the default /etc/init.d/alsa
used to do the necessary modprobing - it's been revised not to do this,
so that it cooperates better with packages that do The Right Thing™
by themselves (under certain circumstances at least), like
hotplug.)
alias char-major-116 snd
alias char-major-14 soundcore
options snd major=116 cards_limit=4 device_mode=0660 device_gid=29 device_uid=0
# or if you use devfs (gid=29 is 'audio' on Debian)
# options snd major=116 cards_limit=4 device_mode=0660 device_gid=29 device_uid=0
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
# my Powerbook has a built-in 'Snapper' sound chip (snd-powermac) and nothing
# else. Replace snd-powermac as appropriate
alias snd-card-0 snd-powermac
alias snd-card-1 off
alias snd-card-2 off
alias snd-card-3 off
alias snd-card-4 off
alias snd-card-5 off
alias snd-card-6 off
alias snd-card-7 off
alias sound-slot-0 snd-card-0
alias sound-slot-1 off
alias sound-slot-2 off
alias sound-slot-3 off
alias sound-slot-4 off
alias sound-slot-5 off
alias sound-slot-6 off
alias sound-slot-7 off
/etc/libao.conf
This will make all libao applications default to the ALSA
driver and its software mixer, instead of OSS emulation: this affects
mpg321, ogg123 and hopefully others.
default_driver=alsa09
~/bin/snd
This is a quick hack to mute/unmute my Powerbook's audio channels. Usage:
- snd i (also snd internal, snd pcspeaker, snd speaker)
- Use internal ‘PC speaker’ (the speakers next to the keyboard)
- snd e (also snd external, snd headphones)
- Use external headphone port (also useful as a line-out to proper speakers that do bass and stuff)
- snd m (also snd mute, snd neither)
- Disable sound for lack of disturbance, and possibly also better battery life
- snd b (also snd both)
- Use both, in theory (but doesn't seem to work)
#!/bin/sh
case "$1" in
# Internal speaker ("PC speaker")
i*|p*|s*)
/usr/sbin/alsactl restore
amixer sset Master off
amixer sset 'PC Speaker' on
amixer sset Headphone off
amixer sset Master on
;;
# External speakers or headphones
e*|h*)
/usr/sbin/alsactl restore
amixer sset Master off
amixer sset 'PC Speaker' off
amixer sset Headphone on
amixer sset Master on
;;
# Mute (neither)
m*|n*)
amixer sset Master off
amixer sset 'PC Speaker' off
amixer sset Headphone off
;;
# Both? currently seems to be just the headphones
b*)
amixer sset Master off
amixer sset 'PC Speaker' on
amixer sset Headphone on
amixer sset Master on
;;
*)
echo "usage: snd {internal|external|both|mute}"
exit 1
;;
esac