The system-wide configuration file is stored in
'/etc/asound.conf', all ALSA compliant applications will read
this file each time they start. The best place to look to get a
sense of your current sound devices is here in '/proc/asound/'.
If you don't have a configuration file, ALSA applications will
use /proc/asound/card0 as the default sound device. You can check
what verison of ALSA you're running here '/proc/asound/version'.
Each sound device has a bunch of 'pcms' associated with it. Each
pcm is basically an output channel: "front", "rear",
"surround41", "surround51", etc. You can see which pcm channels
are available by using this command:
aplay -L | grep CARD
A few of these pcm channels do not correspond to physical audio
outputs but are software channels provided by ALSA. The one we're
interested in is called 'dmix'. The 'dmix' channel is a software
mixer provided by ALSA to handle multiple concurrent input
streams.
One thing to note is the use of multiple conventions for
identifying a particular sound device. The configuration file
will use card0, card1, etc or simply 0, 1, etc. It's also
possible to refer to the card by name, such as Creative, Nvidia,
etc. These names are defined as soft links in the ALSA proc
directory: 'ls -l /proc/asound'. Typically, when referring to a
PCM channel in the configuration file, the format is as follows:
"channel-name:card-index,sub-index". So, for example, "dmix:2,0"
refers to the dmix pcm channel on card 2, sub-device 0. You see
the sub devices associated with each sound card by using this
command:
aplay -l
The final step is the configuration file itself, located here
'/etc/asound.conf'. We need 2 components in this file, a 'pcm'
channel definition and a 'ctl' channel definition. The 'pcm'
channel defines our output and is responsible for multiplexing
multiple sound streams into a single hardware output channel. The
'ctl' channel is used for the mixer and is responsible for
controlling volume.
ALSA uses a software pcm channel called a 'plug' which handles
the multiplexing. It is a software front-end for a slaved pcm
output channel. The slaved pcm output channel must itself be
capable of mixing. An example configuration file follows:
pcm.custom
{
type plug
slave
{
pcm "dmix:2,0"
}
}
ctl.custom
{
type hw
card Creative
}
pcm.!default pcm.custom
ctl.!default ctl.custom
In this case, I'm using the 'dmix' output channel for the 3rd
sound device on the system "dmix:2,0". The 3rd index is 2 because
it starts from 0 (card0, card1, card2). In addition, 'ctl' schema
references the same card but this time using it's soft-linked
name 'Creative'.
I hope this is of use to others.