<?xml version='1.0' encoding="UTF-8"?>
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/alsa-guide.xml,v 1.87 2012/05/27 22:21:53 nightmorph Exp $ -->

<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide>
<title>Gentoo Linux ALSA Guide</title>

<author title="Author">
  <mail link="fox2mike@gentoo.org">Shyam Mani</mail>
</author>
<author title="Author">
  <mail link="nightmorph@gentoo.org">Joshua Saddler</mail>
</author>
<author title="Contributor">
  <mail link="flameeyes@gentoo.org">Diego Pettenò</mail>
</author>

<abstract>
This document helps a user setup ALSA on Gentoo Linux.
</abstract>

<!-- The content of this document is licensed under the CC-BY-SA license -->
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
<license/>

<version>4</version>
<date>2012-05-27</date>

<chapter>
<title>Introduction</title>
<section>
<title>What is ALSA?</title>
<body>

<p>
ALSA, which stands for <e>Advanced Linux Sound Architecture</e>, provides audio
and MIDI (<e>Musical Instrument Digital Interface</e>) functionality to the
Linux operating system. ALSA is the default sound subsystem in the 3.x and 2.6
kernels, thereby replacing OSS (<e>Open Sound System</e>), which was used in
the 2.4 kernels.
</p>

<p>
ALSA's main features include efficient support for all types of audio
interfaces ranging from consumer sound cards to professional sound
equipment, fully modularized drivers, SMP and thread safety, backward
compatibility with OSS and a user-space library <c>alsa-lib</c> to make
application development a breeze.
</p>

</body>
</section>
</chapter>

<chapter>
<title>Installing ALSA</title>
<section id="lspci">
<title>Before you proceed</title>
<body>

<p>
First, you need to know what drivers your sound card uses. In most cases, sound
cards (onboard and otherwise) are PCI based and <c>lspci</c> will help you in
digging out the required information.  Please <c>emerge sys-apps/pciutils</c> to
get <c>lspci</c>, if you don't have it installed already. In case you have a USB
sound card, <c>lsusb</c> from <c>sys-apps/usbutils</c> <e>might</e> be of help.
For ISA cards, try using <c>sys-apps/isapnptools</c>. Also, the following pages
<e>may</e> help users with ISA based sound cards:
</p>

<ul>
  <li>
  <uri link="http://www.roestock.demon.co.uk/isapnptools/">The ISAPNPTOOLS
  Page</uri>
  </li>
  <li>
  <uri link="http://www2.linuxjournal.com/article/3269">LinuxJournal PnP
  Article</uri>
  </li>
  <li>
  <uri link="http://www.tldp.org/HOWTO/Sound-HOWTO/x320.html">TLDP Sound
  HowTo</uri>
  </li>
</ul>

<note>
For ease of use/explanation, we assume the user has a PCI based sound card for
the remainder of this guide.
</note>

<p>
We now proceed to find out details about the sound card.
</p>

<pre caption="Soundcard Details">
# <i>lspci -v | grep -i audio</i>
0000:00:0a.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 06)
</pre>

<p>
We now know that the sound card on the machine is a Sound Blaster Live! and the
card manufacturer is Creative Labs. Head over to the <uri
link="http://bugtrack.alsa-project.org/main/index.php/Matrix:Main">ALSA
Soundcard Matrix</uri> page and select Creative Labs from the list. You will
be taken to the Creative Labs matrix page where you can see that the SB Live!
uses the <c>emu10k1</c> module. That is the information we need for now. If
you are interested in detailed information, you can click on the link next to
the "Details" and that will take you to the <c>emu10k1</c> specific page.
</p>

<p>
If you intend to use MIDI, then you should add <c>midi</c> to your USE flags in
<path>/etc/make.conf</path> before emerging any ALSA packages. Later in the
guide, we will show you how to set up <uri link="#midi">MIDI support</uri>.
</p>

</body>
</section>
<section id="kernel">
<title>Configuring the kernel</title>
<body>

<note>
Since the 2005.0 release, Gentoo Linux uses 2.6 as the default kernel. Please
check that your kernel is a 2.6 series kernel. This method will <e>not</e> work
on a 2.4 kernel.
</note>

<p>
Let us now configure the kernel to enable ALSA.
</p>

<impo>
<c>genkernel</c> users should now run <c>genkernel --menuconfig all</c> and
then follow the instructions in <uri link="#doc_chap2_pre3">Kernel Options for
ALSA</uri>.
</impo>

<pre caption="Heading over to the source">
# <i>cd /usr/src/linux</i>
# <i>make menuconfig</i>
</pre>

<note>
The above example assumes that <path>/usr/src/linux</path> symlink points to
the kernel sources you want to use. Please ensure the same before proceeding.
</note>

<p>
Now we will look at some of the options we will have to enable in the 2.6
kernel to ensure proper ALSA support for our sound card.
</p>

<p>
Please note that for ease of use, all examples show ALSA built as modules. It
is advisable to follow the same as it then allows the use of <c>alsaconf</c>
which is a boon when you want to configure your card. Please do <e>not</e> skip
the <uri link="#alsa-config">Configuration</uri> section of this document. If
you still like to have options built-in, ensure that you make changes to your
config accordingly.
</p>

<pre caption="Kernel Options for ALSA">
Device Drivers  ---&gt;
   Sound  ---&gt;
   
<comment>(This needs to be enabled)</comment>
&lt;M&gt; Sound card support

<comment>(Make sure OSS is disabled)</comment>
Open Sound System   ---&gt;
   &lt; &gt; Open Sound System (DEPRECATED)

<comment>(Move one step back and enter ALSA)</comment>
Advanced Linux Sound Architecture  ---&gt;
   &lt;M&gt; Advanced Linux Sound Architecture
   <comment>(Select this if you want MIDI sequencing and routing)</comment>
   &lt;M&gt; Sequencer support
   <comment>(Old style /dev/mixer* and /dev/dsp* support. Recommended.)</comment>
   &lt;M&gt; OSS Mixer API
   &lt;M&gt; OSS PCM (digital audio) API 

<comment>(You now have a choice of devices to enable support for. Generally,
you will have one type of device and not more. If you have more than one
sound card, please enable them all here.)</comment>

<comment>(Mostly for testing and development purposes, not needed for normal
users unless you know what you are doing.)</comment>
Generic devices  ---&gt;
   
<comment>(For ISA Sound cards)</comment>
ISA devices   ---&gt;
<comment>(IF you had the Gravis, you would select this option)</comment>
   &lt;M&gt; Gravis UltraSound Extreme

<comment>(Move one level back and into PCI devices. Most sound cards today are
PCI devices)</comment>
PCI devices   ---&gt;
   <comment>(We now select the emu10k1 driver for our card)</comment>
   &lt;M&gt; Emu10k1 (SB Live!, Audigy, E-mu APS)
   <comment>(Or an Intel card would be)</comment>
   &lt;M&gt; Intel/SiS/nVidia/AMD/ALi AC97 Controller
   <comment>(Or if you have a VIA Card)</comment>
   &lt;M&gt; VIA 82C686A/B, 8233/8235 AC97 Controller

<comment>(Move one level back and select in case you have an USB sound card)</comment>
USB Devices   ---&gt;
</pre>

<p>
Now that your options are set, you can (re)compile the kernel and ALSA support
for your card should be functional once you reboot into the new kernel. Don't
forget to update your GRUB configuration to use the newly built kernel.
You can now proceed to <uri link="#alsa-utilities">ALSA Utilities</uri> and
see if everything is working as it should.
</p>

</body>
</section>
</chapter>

<chapter>
<title>Configuring/Testing ALSA</title>
<section id="alsa-utilities">
<title>ALSA Utilities</title>
<body>

<p>
<c>alsa-utils</c> forms an integral part of ALSA as it has a truckload of
programs that are highly useful, including the ALSA Initscripts. Hence we
strongly recommend that you install <c>alsa-utils</c>
</p>

<pre caption="Install alsa-utils">
# <i>emerge alsa-utils</i>
</pre>

<note>
If you did <e>not</e> compile ALSA as modules, please proceed to the <uri
link="#initscript">ALSA Initscript</uri> section. The rest of you need to
configure ALSA. This is made very easy by the existence of the <c>alsaconf</c>
tool provided by <c>alsa-utils</c>.
</note>

</body>
</section>
<section id="alsa-config">
<title>Configuration</title>
<body>

<p>
Recent versions of <c>udev</c> (<c>>=udev-103</c>) provide some degree of
kernel-level autoconfiguration of your sound card. If possible, try to rely on
just letting your kernel automatically setup your sound card for you. Otherwise,
use <c>alsaconf</c> to configure your card, as shown below.
</p>

<note>
Please shut down any programs that <e>might</e> access the sound card while
running <c>alsaconf</c>.
</note>

<p>
To configure your sound card just type <c>alsaconf</c> in a shell as root.
</p>

<pre caption="Invoking alsaconf">
# <i>alsaconf</i>
</pre>

<p>
You will now see a neat menu guided interface that will automatically probe
your devices and try to find out your sound card. You will be asked to pick
your sound card from a list. Once that's done, it will ask you permission to
automatically make required changes to <path>/etc/modprobe.d/alsa.conf</path>.
It will then adjust your volume settings to optimum levels, run
<c>update-modules</c> and start the <path>/etc/init.d/alsasound</path> service.
Once <c>alsaconf</c> exits, you can proceed with setting up the ALSA
initscript. 
</p>

</body>
</section>
<section id="initscript">
<title>ALSA Initscript</title>
<body>

<p>
We're now almost all setup. Whichever method you chose to install ALSA, you'll
need to have something load your modules or initialize ALSA and restore your
volume settings when your system comes up. The ALSA Initscript handles all of
this for you and is called <c>alsasound</c>. Add it to the boot runlevel.
</p>

<pre caption="Adding ALSA to the boot runlevel">
# <i>rc-update add alsasound boot</i>
 * alsasound added to runlevel boot
 * rc-update complete.
</pre>

<p>
Next, just check the <path>/etc/conf.d/alsasound</path> file and ensure that
SAVE_ON_STOP variable is set to yes. This saves your sound settings when you
shutdown your system.
</p>

</body>
</section>
<section>
<title>Audio Group</title>
<body>

<p>
Before we move on to testing, there's one last <e>important</e> thing that needs
to be setup. Rule of thumb in a *nix OS: Do not run as root unless needed.
This applies here as well ;) How? Well, most of the times you should be logged
in as a user and would like to listen to music or access your soundcard. For
that to happen, you need to be in the "audio" group. At this point, we'll add
users to the audio group, so that they won't have any issues when they want to
access sound devices. We'll use <c>gpasswd</c> here and you need to be logged in
as root for this to work.
</p>

<pre caption="Adding users to the audio group">
<comment>(Substitute &lt;username&gt; with your user)</comment>
# <i>gpasswd -a &lt;username&gt; audio </i>
Adding user &lt;username&gt; to group audio
</pre>

</body>
</section>
<section>
<title>Volume Check!</title>
<body>

<p>
We've completed all the setups and prerequisites, so let's fire up ALSA. If
you ran <c>alsaconf</c>, you can skip this step, since <c>alsaconf</c> already
does this for you.
</p>

<pre caption="Start the service">
# <i>/etc/init.d/alsasound start</i>
</pre>

<p>
Now that the required things have been taken care of, we need to check up on
the volume as in certain cases, it is muted. We use <c>alsamixer</c> for this
purpose.
</p>

<pre caption="Starting alsamixer">
<comment>(Opens up a console program. Only required settings are shown)</comment>
# <i>alsamixer</i>
</pre>

<p>
This is how the ALSA Mixer <e>might</e> look the first time you open it. Pay
attention to the Master and PCM channels which both have an MM below them.
That means they are muted. If you try to play anything with <c>alsamixer</c>
in this state, you will not hear anything on your speakers.
</p>

<figure link="/images/docs/alsa-mixermuted.png" short="AlsaMixer Muted" caption="The Alsa Mixer Main Window, Muted"/>

<p>
Now, we shall unmute the channels, and set volume levels as needed.
</p>

<warn>
Both Master <e>and</e> PCM need to be unmuted and set to audible volume levels
if you want to hear some output on your speakers.
</warn>

<ul>
  <li>
  To move between channels, use your left and right arrow keys. (&lt;-
  &amp; -&gt;)
  </li>
  <li>
  To toggle mute, move to the specific channel, for example Master and press
  the <e>m</e> key on the keyboard.
  </li>
  <li>
  To increase and decrease the volume levels, use the up and down arrow keys
  respectively.
  </li>
</ul>

<note>
Be careful when setting your Bass and Treble values. 50 is usually a good
number for both. Extremely high values of Bass may cause <e>jarring</e>
on speakers that are not designed to handle them.
</note>

<p>
After you're all done, your ALSA Mixer should look similar to the one below.
Note the 00 instead of the MM and also the volume levels for some optimum
settings.
</p>

<figure link="/images/docs/alsa-mixerunmuted.png" short="AlsaMixer Unmuted" caption="Alsa Mixer ready to roll"/>

</body>
</section>
<section>
<title>Sound Check!</title>
<body>

<p>
Finally. Some music. If everything above is perfect, you should now be able to
listen to some good music. A quick way to test is to use a command line tool
like <c>media-sound/madplay</c>. You could also use something more well known
like <c>mpg123</c>. If you are an ogg fan, you could use <c>ogg123</c> provided
by <c>media-sound/vorbis-tools</c>. Use any player you are comfortable with. As
always, <c>emerge</c> what you need.
</p>

<pre caption="Getting the software">
<comment>(Install the applications you want)</comment>
# <i>emerge madplay mpg123</i>
<comment>(To play .ogg files)</comment>
# <i>emerge vorbis-tools</i>
</pre>

<p>
And then play your favorite sound track...
</p>

<pre caption="Playing Music">
# <i>madplay -v /mnt/shyam/Music/Paul\ Oakenfold\ -\ Dread\ Rock.mp3</i>
MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
          Title: Dread Rock
         Artist: Paul Oakenfold
          Album: Matrix Reloaded
           Year: 2003
          Genre: Soundtrack
                 Soundtrack
 00:04:19 Layer III, 160 kbps, 44100 Hz, joint stereo (MS), no CRC

# <i>ogg123 Paul\ Oakenfold\ -\ Dread\ Rock.ogg</i>
Audio Device:   Advanced Linux Sound Architecture (ALSA) output

Playing: Paul Oakenfold - Dread Rock.ogg
Ogg Vorbis stream: 2 channel, 44100 Hz
Genre: Soundtrack
Transcoded: mp3;160
Title: Dread Rock
Artist: Paul Oakenfold
Date: 2003
Album: Matrix Reloaded
Time: 00:11.31 [04:28.75] of 04:40.06  (200.6 kbps)  Output Buffer  96.9%
</pre>

</body>
</section>
<section>
<title>ALSA and USE</title>
<body>

<p>
You can now add the <c>alsa</c> use flag to <path>/etc/make.conf</path> to
ensure that your applications that support ALSA get built with it. Some
architectures like x86 and amd64 have the flag enabled by default.
</p>

</body>
</section>
<section>
<title>Issues?</title>
<body>

<p>
If for some reason you're unable to hear sound, the first thing to do would
be to check your <uri link="#doc_chap3_pre6">alsamixer</uri> settings. 80% of
the issues lie with muted channels or low volume. Also check your Window
Manager's sound applet and verify that volumes are set to audible levels.
</p>

<p>
<path>/proc</path> is your friend. And in this case, <path>/proc/asound</path>
is your best friend. We shall just take a short look at how much info is made
available to us there.
</p>

<pre caption="Fun with /proc/asound">
<comment>(First and foremost, if /proc/asound/cards shows your card, ALSA has
picked up your sound card fine.)</comment>
# <i>cat /proc/asound/cards</i>
0 [Live           ]: EMU10K1 - Sound Blaster Live!
                     Sound Blaster Live! (rev.6, serial:0x80271102) at 0xb800, irq 11

<comment>(This displays the current running ALSA version)</comment>
# <i>cat /proc/asound/version</i>
Advanced Linux Sound Architecture Driver Version 1.0.8 (Thu Jan 13 09:39:32 2005 UTC).

<comment>(ALSA OSS emulation details)</comment>
# <i>cat /proc/asound/oss/sndstat</i>
Sound Driver:3.8.1a-980706 (ALSA v1.0.8 emulation code)
Kernel: Linux airwolf.zion 2.6.11ac1 #2 Wed May 4 00:35:08 IST 2005 i686
Config options: 0

Installed drivers:
Type 10: ALSA emulation

Card config:
Sound Blaster Live! (rev.6, serial:0x80271102) at 0xb800, irq 11

Audio devices:
0: EMU10K1 (DUPLEX)

Synth devices: NOT ENABLED IN CONFIG

Midi devices:
0: EMU10K1 MPU-401 (UART)

Timers:
7: system timer

Mixers:
0: SigmaTel STAC9721/23
</pre>

<!-- TODO: remove this a few months after alsa-driver leaves the tree -->

<p>
The other most common issue users face is the dreaded "Unknown symbol in module"
error. An example of the same is shown below.
</p>

<pre caption="Unknown Symbol in module error">
# <i>/etc/init.d/alsasound start</i>
 * Loading ALSA modules ...
 *   Loading: snd-card-0 ...                                              [ ok ]
 *   Loading: snd-pcm-oss ...
WARNING: Error inserting snd_mixer_oss
(/lib/modules/2.6.12-gentoo-r6/kernel/sound/core/oss/snd-mixer-oss.ko): Unknown
symbol in module, or unknown parameter (see dmesg) FATAL: Error inserting
snd_pcm_oss
(/lib/modules/2.6.12-gentoo-r6/kernel/sound/core/oss/snd-pcm-oss.ko): Unknown
symbol in module, or unknown parameter (see dmesg)                             
                                                                          [ !! ]
 *   Loading: snd-mixer-oss ...
FATAL: Error inserting snd_mixer_oss
(/lib/modules/2.6.12-gentoo-r6/kernel/sound/core/oss/snd-mixer-oss.ko): Unknown
symbol in module, or unknown parameter (see dmesg)                             
                                                                          [ !! ]
 *   Loading: snd-seq ...                                                 [ ok ]
 *   Loading: snd-emu10k1-synth ...                                       [ ok ]
 *   Loading: snd-seq-midi ...                                            [ ok ]
 * Restoring Mixer Levels ...                                             [ ok ]
</pre>

<p>
And when you take a look at <c>dmesg</c> as suggested, you're quite likely to
see:
</p>

<pre caption="dmesg output">
<comment>(Only relevant portions are shown below)</comment>
# <i>dmesg | less</i>
ACPI: PCI Interrupt 0000:02:06.0[A] -> Link [APC3] -> GSI 18 (level, low) -> IRQ 209
snd_mixer_oss: Unknown symbol snd_unregister_oss_device
snd_mixer_oss: Unknown symbol snd_register_oss_device
snd_mixer_oss: Unknown symbol snd_mixer_oss_notify_callback
snd_mixer_oss: Unknown symbol snd_oss_info_register
snd_pcm_oss: Unknown symbol snd_unregister_oss_device
snd_pcm_oss: Unknown symbol snd_register_oss_device
snd_pcm_oss: Unknown symbol snd_mixer_oss_ioctl_card
snd_pcm_oss: Unknown symbol snd_oss_info_register
snd_mixer_oss: Unknown symbol snd_unregister_oss_device
snd_mixer_oss: Unknown symbol snd_register_oss_device
snd_mixer_oss: Unknown symbol snd_mixer_oss_notify_callback
snd_mixer_oss: Unknown symbol snd_oss_info_register
</pre>

<p>
The above issue is caused when you switch from the <c>alsa-driver</c> to in-kernel
ALSA because when you unmerge <c>alsa-driver</c> the module files are config
protected and hence get left behind. So, when you switch to in-kernel
drivers, running <c>modprobe</c> gives you a mix of <c>alsa-driver</c> and
in-kernel modules thus causing the above errors.
</p>

<p>
The solution is quite easy. We just need to manually remove the problem causing
directory after you unmerge <c>alsa-driver</c>. Be sure to remove the correct
kernel version and not the current one!
</p>

<pre caption="Removing the alsa-driver modules">
# <i>rm -rf /lib/modules/$(uname -r)/alsa-driver</i>
</pre>

<p>
Another reason for error messages similar to the ones above could be a file in
<path>/etc/modprobe.d</path> supplying a <c>device_mode</c> parameter when it
isn't required. Confirm that this is indeed the issue and find out which file
is the culprit.
</p>

<pre caption="Confirming and searching for device_mode">
<comment>(Check dmesg to confirm)</comment>
# <i>dmesg | grep device_mode</i>
snd: Unknown parameter `device_mode'
<comment>(Now, to get to the source of the issue)</comment>
# <i>grep device_mode /etc/modprobe.d/*</i>
</pre>

<p>
Usually it is a file called <path>alsa</path> with the line <c>options snd
device_mode=0666</c>. Remove this line and restart the <c>alsasound</c> service
and that should take care of this issue.
</p>

<!-- End of removal notice -->

</body>
</section>
</chapter>

<chapter>
<title>Other things ALSA</title>
<section id="midi">
<title>Setting up MIDI support</title>
<body>

<p>
First, check to make sure that you enabled the <c>midi</c> USE flag in
<path>/etc/make.conf</path>. If you didn't, go ahead and add it now. You will
also need to re-emerge any ALSA packages that use the <c>midi</c> flag, such as
<c>alsa-lib</c> and <c>alsa-utils</c>.
</p>

<p>
If your sound card is one of those that come with on-board MIDI synthesizers
and you would like to listen to some .mid files, you have to install
<c>awesfx</c> which is basically a set of utilities for controlling the AWE32
driver. We need to install it first. If you don't have a hardware synthesizer,
you can use a virtual one. Please see the section on
<uri link="#vsynth">Virtual Synthesizers</uri> for more information.
</p>

<pre caption="Installing awesfx">
# <i>emerge awesfx</i>
</pre>

<note>
You will need to copy over SoundFont (SF2) files from your sound card's driver
CD or a Windows installation into <path>/usr/share/sounds/sf2/</path>. For
example a sound font file for the Creative SBLive! card would be 8MBGMSFX.SF2.
</note>

<p>
After copying over the Soundfont files, we can then play a midi file as shown.
You can also add the <c>asfxload</c> command to
<path>/etc/conf.d/local.start</path>, so that the sound font is loaded
every time the system starts up.
</p>

<note>
<path>/mnt</path> paths mentioned in the code listing(s) below will <e>not</e>
be the same in your machine. They are just an example. Please be careful to
change the path to suit your machine.
</note>

<pre caption="Loading Soundfonts">
<comment>(First, copy the Soundfont)</comment>
# <i>cp /mnt/win2k/Program\ Files/CreativeSBLive2k/SFBank/8MBGMSFX.SF2 /usr/share/sounds/sf2/</i> 
<comment>(Or get it from your SoundBlaster CD)</comment>
# <i>cp /mnt/cdrom/AUDIO/ENGLISH/SFBANK/8MBGMSFX.SF2 /usr/share/sounds/sf2/</i>
<comment>(We load the specific Soundfont)</comment>
# <i>asfxload /usr/share/sounds/sf2/8MBGMSFX.SF2</i>
</pre>

<p>
You can now play midi files using a program like <c>aplaymidi</c>. Run
<c>aplaymidi -l</c> to get a list of available ports and then pick one
to play the file on.
</p>

<pre caption="Playing MIDI">
<comment>(Check open ports)</comment>
# <i>aplaymidi -l</i>
 Port    Client name                      Port name
 64:0    EMU10K1 MPU-401 (UART)           EMU10K1 MPU-401 (UART)
 65:0    Emu10k1 WaveTable                Emu10k1 Port 0
 65:1    Emu10k1 WaveTable                Emu10k1 Port 1
 65:2    Emu10k1 WaveTable                Emu10k1 Port 2
 65:3    Emu10k1 WaveTable                Emu10k1 Port 3
<comment>(Pick a port, and play a mid file)</comment>
# <i> aplaymidi --port=65:0 /mnt/shyam/music/midi/mi2.mid</i>
</pre>

</body>
</section>
<section id="vsynth">
<title>Virtual Synthesizers</title>
<body>

<p>
If your sound card lacks a hardware synthesizer, you could use a virtual one
like <c>timidity++</c>. Installation is a breeze.
</p>

<pre caption="Installing timidity++">
# <i>emerge timidity++</i>
</pre>

<p>
For timidity to play sounds, it needs a sound font. Fortunately, the ebuild will
install some sound font packages for you. There are a few other font packages
available in Portage, such as <c>timidity-freepats</c> and
<c>timidity-eawpatches</c>. You can have multiple sound font configurations
installed, and you can place your own in <path>/usr/share/timidity/</path>. To
switch between different timidity configurations, you should use
<c>eselect</c>.
</p>

<pre caption="Changing configurations">
# <i>eselect timidity list</i>
# <i>eselect timidity set eawpatches</i>
</pre>

<p>
Don't forget to add <c>timidity</c> to the default runlevel.
</p>

<pre caption="Adding timidity to the default runlevel">
# <i>rc-update add timidity default</i>
# <i>/etc/init.d/timidity start</i>
</pre>

<p>
You can now try out <uri link="#doc_chap4_pre3">Playing MIDI</uri> files.
</p>

</body>
</section>
<section>
<title>Tools and Firmware</title>
<body>

<p>
Some specific sound cards can benefit from certain tools provided by the
<c>alsa-tools</c> and <c>alsa-firmware</c> packages. You may install either with
a simple <c>emerge</c>.
</p>

<pre caption="Installing ALSA Tools">
# <i>emerge alsa-tools</i>
</pre>

</body>
</section>
<section>
<title>Multiple sound cards</title>
<body>

<p>
You can have more than one sound card in your system simultaneously, provided
that you have built ALSA as modules in your kernel. You just need to specify
which should be started first in <path>/etc/modprobe.d/alsa.conf</path>. Your cards
are identified by their driver names inside this file. 0 is the first card, 1 is
the second, and so on. Here's an example for a system with two sound cards.
</p>

<pre caption="Two sound cards in /etc/modprobe.d/alsa.conf">
options snd-emu10k1 index=0
options snd-via82xx index=1
</pre>

<p>
Or, if you have two cards that use the same driver, you specify them on the same
line, using comma-separated numbers. Here's an example for a system with three
sound cards, two of which are the same Intel High Definition Audio card.
</p>

<pre caption="Multiple sound cards in /etc/modprobe.d/alsa.conf">
options snd-ymfpci index=0
options snd-hda-intel index=1,2
</pre>

</body>
</section>
<section>
<title>Plugins</title>
<body>

<p>
You may want to install some plugins for extra functionality.
<c>alsa-plugins</c> is a collection of useful plugins, which include: PulseAudio
output, a sample rate converter, jack (a low-latency audio server), and an
encoder that lets you output 6-channel audio through digital S/PDIF connections
(both optical and coaxial). You can choose which of its plugins you want
installed by adding their USE flags to <path>/etc/portage/package.use</path>.
</p>

<pre caption="Installing alsa-plugins">
# <i>emerge -avt alsa-plugins</i>
</pre>

</body>
</section>
<section>
<title>A big thank you to...</title>
<body>

<p>
Everyone who contributed to the earlier version of the Gentoo ALSA Guide:
Vincent Verleye, Grant Goodyear, Arcady Genkin, Jeremy Huddleston,
John P. Davis, Sven Vermeulen, Benny Chuang, Tiemo Kieft and Erwin.
</p>

</body>
</section>
<section>
<title>References</title>
<body>

<ul>
  <li><uri link="http://www.alsa-project.org/">The ALSA Project</uri></li>
  <li><uri link="http://linux-sound.org">Linux Sound/MIDI Software</uri></li>
</ul>

</body>
</section>
</chapter>
</guide>
