ALSA Configuration (In Depth)
From low-art Gloominati
I finally had a reason to get into ALSA in more depth, so this page will summarize what I learned as well as describe my dual card setup.... but not right now, b/c I am tired :). For now I am just dropping random bits of info here.
[edit] Current setup in /etc/asound.conf
# Here is a diagram of what this config does:
#
# 'nforce' nForce2,0
# 4-channel _______________ ____________
# SOFTVOL ROUTE MULTI 0L | PLUG | | |
# ______________ __________ _________ /------->| convert |------>| |
# 0L | | 0L | | 0L | | / | rate & format | | Sound card |
# ------->| Software |------>|\---------|---->|---------|- 1R | for HW | | |
# | volume | | \ | | | /------->| |------>| |
# 1R | attenuation | 1R | \ | 1R | | / |_______________| |____________|
# ------->| |------>|---\------|---->|---------|- _______________
# |______________| |\ \ | 2L | | 0L | PLUG | ____________
# 'softvol' | \ \----|---->|---------|---------->| convert |------>| |
# | \ | 3R | | 1R | rate & format | | Sound card |
# | \------|---->|---------|---------->| for HW |------>| |
# |__________| |_________| |_______________| |____________|
# 'both' 'multi' 'audiophile' M2496,0
#
#
################################################## BEGIN ##################################################
# Give our cards friendly aliases. Note that we are wrapping the cards with 'plug' plugin
# in order to perform automatic conversion of the stream from the original format into
# the format suitable for each individual card.
#
pcm.nforce "plughw:nForce2,0"
pcm.audiophile "plughw:M2496,0"
pcm.!default main_device
# 'asym' plugin allows us to create assymetrical devices which have different
# interfaces handling playback and recording streams.
# This configuration ensures that playback is sent through the complicated routing,
# but recording streams are fetched directly from Audiophile
#
pcm.main_device {
type asym
playback.pcm "softvol"
capture.pcm "audiophile"
}
# This device acts as a software volume control
pcm.softvol {
type softvol
slave {
pcm "both"
}
control {
name "SoftMaster" # This is the name of the mixer control
card M2496
}
}
# Here we are using the 'route' plugin to send the signal unchanged to a
# 4-channel device. Since the incoming stream is only 2-channel, we use
# the transfer table to copy channel 0 slave's input channel 0,
# channel 1 to slave's 1, and again channel 0 to slave's 2 and channel 1
# to slave's 3. The last column (1.0) is the volume, which we are leaving unchanged
#
pcm.both {
type route
slave {
pcm multi
channels 4
}
ttable.0.0 1.0
ttable.1.1 1.0
ttable.0.2 1.0
ttable.1.3 1.0
}
# 'multi' plugin allows us to create many slave devices and then distribute the stream's
# channels between the slaves.
# Here we define Slave a for the nforce card (headphones) and Slave b for the Audiophile.
# Then we use channel binding to send channels 0 and 1 to the headphones and channels
# 2 and 3 to the speakers
#
pcm.multi {
type multi
slaves.a {
pcm "nforce"
channels 2
}
slaves.b {
pcm "audiophile"
channels 2
}
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave b
bindings.2.channel 0
bindings.3.slave b
bindings.3.channel 1
}
pcm.dsp0 {
type plug
slave.pcm "softvol"
}
ctl.main_device {
type hw
card M2496
}
[edit] How can I find which processes are using Alsa devices?
fuser -v /dev/snd/*
[edit] Misc
http://www.volkerschatz.com/noise/alsa.html
http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
http://www.mythtv.org/pipermail/mythtv-users/2005-June/091327.html
http://quicktoots.linuxaudio.org/toots/el-cheapo/
/usr/share/alsa/alsa.conf
- Use alsaplayer for detailed error messages when the setup doesn't work at all.
- Use aplay -v to see all of the routing details when we can write to whatever device we are testing.

