/[gentoo]/xml/htdocs/doc/en/alsa-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/alsa-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.17 Revision 1.56
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/alsa-guide.xml,v 1.56 2005/07/14 09:11:02 neysx Exp $ -->
3
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 5
4<guide link = "/doc/en/alsa-guide.xml"> 6<guide link="/doc/en/alsa-guide.xml">
5<title>Gentoo Linux ALSA Guide</title> 7<title>Gentoo Linux ALSA Guide</title>
6<author title="Author"><mail link="zu@pandora.be"> 8
7 Vincent Verleye</mail> 9<author title="Author">
10 <mail link="fox2mike@gentoo.org">Shyam Mani</mail>
8</author> 11</author>
9<author title="Author"><mail link="g2boojum@gentoo.org">
10 Grant Goodyear</mail>
11</author>
12<author title="Author"><mail link="agenkin@gentoo.org">
13 Arcady Genkin</mail>
14</author>
15<author title="Editor"><mail link="zhen@gentoo.org">
16 John P. Davis</mail>
17</author>
18<author title="Editor"><mail link="swift@gentoo.org">
19 Sven Vermeulen</mail>
20</author>
21<author title="Editor"><mail link="bennyc@gentoo.org">
22 Benny Chuang</mail>
23</author>
24<author title="Editor"><mail link="blubber@gentoo.org">
25 Tiemo Kieft</mail>
26</author>
27 12
13<abstract>
14This document helps a user setup ALSA on Gentoo Linux.
15</abstract>
16
17<!-- The content of this document is licensed under the CC-BY-SA license -->
18<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
28<license/> 19<license/>
29 20
30<abstract>
31This guide will show you how to set up the Advanced Linux Sound Architecture (ALSA) on Gentoo Linux.
32In addition to the Gentoo Linux Desktop Configuration Guide, this guide is supposed to give you more information on this subject. </abstract>
33
34<version>1.3.3</version> 21<version>2.5</version>
35<date>October 9, 2003</date> 22<date>2005-07-14</date>
36 23
37<chapter> 24<chapter>
38<title>Introduction</title> 25<title>Introduction</title>
39<section> 26<section>
40 <title>What is ALSA?</title> 27<title>What is ALSA?</title>
28<body>
29
30<p>
31ALSA, which stands for <e>Advanced Linux Sound Architecture</e>, provides
32audio and MIDI (<e>Musical Instrument Digital Interface</e>) functionality to
33the Linux operating system. ALSA is the default sound subsystem in the 2.6
34kernel thereby replacing OSS (<e>Open Sound System</e>), which was used in the
352.4 kernels.
36</p>
37
38<p>
39ALSA's main features include efficient support for all types of audio
40interfaces ranging from consumer sound cards to professional sound
41equipment, fully modularized drivers, SMP and thread safety, backward
42compatibility with OSS and a user-space library <c>alsa-lib</c> to make
43application development a breeze.
44</p>
45
41<body> 46</body>
42<p> 47</section>
43The Advanced Linux Sound Architecture (ALSA) is a project to improve the Linux sound subsystem by rewriting 48<section>
44large chunks of it. 49<title>ALSA on Gentoo</title>
45It is anticipated that ALSA will make it into Linux kernel 2.6.x (or 3.x.x -- whichever comes first) as it becomes ready. 50<body>
51
46</p> 52<p>
47 53One of Gentoo's main strengths lies in giving the user maximum control over
54how a system is installed/configured. ALSA on Gentoo follows the same
55principle. There are two ways you can get ALSA support up and running on your
56system. We shall look at them in detail in the next chapter.
48<p> 57</p>
49ALSA provides audio and MIDI functionality for Linux. 58
59</body>
60</section>
61</chapter>
62
63<chapter>
64<title>Installing ALSA</title>
65<section>
66<title>Options</title>
67<body>
68
69<warn>
70The methods shown below are mutually exclusive. You cannot have ALSA compiled
71in your kernel and use <c>media-sound/alsa-driver</c>. It <e>will</e> fail.
72</warn>
73
50</p> 74<p>
51 75The two options are :
52<p> 76</p>
53Quoted from <uri>http://www.alsa-project.org</uri>, ALSA has the following features: 77
54<ul><li> Efficient support for all types of audio interfaces, from consumer soundcards to professional multichannel audio interfaces.</li> 78<ol>
55 <li> Fully modularized sound drivers.</li> 79 <li>
56 <li> SMP and thread-safe design.</li> 80 Use ALSA provided by your kernel. This is the preferred/recommended
57 <li> User space library (alsa-lib) to simplify application programming and provide higher level functionality.</li> 81 method.
58 <li> Support for the older OSS API, providing binary compatibility for most OSS programs.</li> 82 </li>
83 <li>
84 Use Gentoo's <c>media-sound/alsa-driver</c> package.
85 </li>
86</ol>
87
88<p>
89We shall take a peek into both before finally deciding on one.
90</p>
91
92<p>
93If you were to use ALSA provided by the kernel, the following are the pros and
94cons :
95</p>
96
97<table>
98<tr>
99 <th>Kernel ALSA</th>
100 <th>Pros and Cons</th>
101</tr>
102<tr>
103 <th>+</th>
104 <ti>Pretty stable as drivers are integrated into kernel.</ti>
105</tr>
106<tr>
107 <th>+</th>
108 <ti>One shot solution, no repeating emerges.</ti>
109</tr>
110<tr>
111 <th>-</th>
112 <ti>Might be a slightly older version than <c>alsa-driver</c>.</ti>
113</tr>
114</table>
115
116<p>
117And, if you were to use alsa-driver,
118</p>
119
120<table>
121<tr>
122 <th>alsa-driver</th>
123 <th>Pros and Cons</th>
124</tr>
125<tr>
126 <th>+</th>
127 <ti>Latest drivers from the ALSA Project.</ti>
128</tr>
129<tr>
130 <th>-</th>
131 <ti>Every kernel recompile requires a re-emerge of <c>alsa-driver</c>.</ti>
132</tr>
133<tr>
134 <th>-</th>
135 <ti>Needs certain kernel config options disabled to work correctly.</ti>
136</tr>
137</table>
138
139</body>
140</section>
141<section>
142<title>So...</title>
143<body>
144
145<p>
146The main difference between using <c>alsa-driver</c> and ALSA that comes with
147the kernel is that <c>alsa-driver</c> is generally more up to date than the
148version in the kernel. Since this does not make any huge difference as
149such, you are encouraged to use the ALSA provided by the kernel.
150</p>
151
152</body>
153</section>
154<section id="lspci">
155<title>Before you proceed</title>
156<body>
157
158<p>
159Whichever method of install you choose, you need to know what drivers your
160sound card uses. In most cases, sound cards (onboard and otherwise) are PCI
161based and <c>lspci</c> will help you in digging out the required information.
162Please <c>emerge sys-apps/pciutils</c> to get <c>lspci</c>, if you don't have it
163installed already. In case you have a USB sound card, <c>lsusb</c> from
164<c>sys-apps/usbutils</c> <e>might</e> be of help. For ISA cards, try using
165<c>sys-apps/isapnptools</c>. Also, the following pages <e>may</e> help users
166with ISA based sound cards.
167</p>
168
169<ul>
170 <li>
171 <uri link="http://www.roestock.demon.co.uk/isapnptools/">The ISAPNPTOOLS
172 Page</uri>
173 </li>
174 <li>
175 <uri link="http://www2.linuxjournal.com/article/3269">LinuxJournal PnP
176 Article</uri>
177 </li>
178 <li>
179 <uri link="http://www.tldp.org/HOWTO/Sound-HOWTO/x320.html">TLDP Sound
180 HowTo</uri>
181 </li>
59</ul> 182</ul>
60There's lots more to ALSA however, like support for Full Duplex playback and recording, multiple soundcard support, 183
61hardware mixing of streams, extensive mixer capabilities (to support advanced features of new soundcards), ... 184<note>
185For ease of use/explanation, we assume the user has a PCI based sound card for
186the remainder of this guide.
187</note>
188
62</p> 189<p>
190We now proceed to find out details about the sound card.
191</p>
192
193<pre caption="Soundcard Details">
194# <i>lspci -v | grep -i audio</i>
1950000:00:0a.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 06)
196</pre>
197
198<p>
199We now know that the sound card on the machine is a Sound Blaster Live! and
200the card manufacturer is Creative Labs. Head over to the
201<uri link="http://www.alsa-project.org/alsa-doc/"> ALSA Soundcard Matrix</uri>
202page and select Creative Labs from the drop down menu. You will be taken to
203the Creative Labs matrix page where you can see that the SB Live! uses the
204<c>emu10k1</c> module. That is the information we need for now. If you are
205interested in detailed information, you can click on the link next to the
206"Details" and that will take you to the <c>emu10k1</c> specific page.
207</p>
208
63</body> 209</body>
64</section>
65<section> 210</section>
66 <title>Why use ALSA?</title> 211<section id="kernel">
67<body> 212<title>Using ALSA provided by your Kernel</title>
68<p>
69If your soundcard is supported by the Linux kernel sound system or the commercial OSS/4Front sound driver system,
70which can be found in all 2.4.x Linux kernels, you could just aswell build <e>those modules</e> for use with your soundcard.
71If you want this, just read through the <uri link="http://www.tldp.org/HOWTO/Sound-HOWTO/index.html">Linux Sound HOWTO</uri>.
72</p>
73<p>
74However, those OSS/4Front drivers have some limitations -- being commercial is one.
75ALSA is an attempt to go beyond these limitations and to do so in an open source fashion.
76ALSA is a fully GPL and LGPL'ed sound driver system, that provides a professional quality system for recording, playback,
77and MIDI sequencing.
78</p>
79</body> 213<body>
80</section> 214
215<p>
216If you're a person who likes to keep things simple like I do, then this is
217the way to go.
218</p>
219
220<note>
221Since the 2005.0 release, Gentoo Linux uses 2.6 as the default kernel. Unless
222you are specifically using the 2.4 profile, <c>gentoo-sources</c> will be a
2232.6 kernel on <e>most</e> architectures. Please check that your kernel is a
2242.6 series kernel. This method will <e>not</e> work on a 2.4 kernel.
225</note>
226
227<p>
228Let us now configure the kernel to enable ALSA.
229</p>
230
231<impo>
232<c>genkernel</c> users should now run <c>genkernel --menuconfig</c> and then follow
233the instructions in <uri link="#doc_chap2_pre3">Kernel Options for ALSA</uri>.
234</impo>
235
236<pre caption="Heading over to the source">
237# <i>cd /usr/src/linux</i>
238# <i>make menuconfig</i>
239</pre>
240
241<note>
242The above example assumes that <path>/usr/src/linux</path> symlink points to
243the kernel sources you want to use. Please ensure the same before proceeding.
244</note>
245
246<p>
247Now we will look at some of the options we will have to enable in the 2.6
248kernel to ensure proper ALSA support for our sound card.
249</p>
250
251<p>
252Please note that for the sake of ease, all examples show ALSA built as modules.
253It is advisable to follow the same as it then allows the use of <c>alsaconf</c>
254which is a boon when you want to configure your card. Please do <e>not</e> skip the <uri
255link="#alsa-config">Configuration</uri> section of this document. If you still
256like to have options built-in, ensure that you make changes to your config
257accordingly.
258</p>
259
260<pre caption="Kernel Options for ALSA">
261Device Drivers ---&gt;
262 Sound ---&gt;
263
264<comment>(This needs to be enabled)</comment>
265&lt;M&gt; Sound card support
266
267<comment>(Make sure OSS is disabled)</comment>
268Open Sound System ---&gt;
269 &lt; &gt; Open Sound System (DEPRECATED)
270
271<comment>(Move one step back and enter ALSA)</comment>
272Advanced Linux Sound Architecture ---&gt;
273 &lt;M&gt; Advanced Linux Sound Architecture
274 <comment>(Select this if you want MIDI sequencing and routing)</comment>
275 &lt;M&gt; Sequencer support
276 <comment>(Old style /dev/mixer* and /dev/dsp* support. Recommended.)</comment>
277 &lt;M&gt; OSS Mixer API
278 &lt;M&gt; OSS PCM (digital audio) API
279
280<comment>(You now have a choice of devices to enable support for. Generally,
281you will have one type of device and not more. If you have more than one
282sound card, please enable them all here.)</comment>
283
284<comment>(Mostly for testing and development purposes, not needed for normal
285users unless you know what you are doing.)</comment>
286Generic devices ---&gt;
287
288<comment>(For ISA Sound cards)</comment>
289ISA devices ---&gt;
290<comment>(IF you had the Gravis, you would select this option)</comment>
291 &lt;M&gt; Gravis UltraSound Extreme
292
293<comment>(Move one level back and into PCI devices. Most sound cards today are
294PCI devices)</comment>
295PCI devices ---&gt;
296 <comment>(We now select the emu10k1 driver for our card)</comment>
297 &lt;M&gt; Emu10k1 (SB Live!, Audigy, E-mu APS)
298 <comment>(Or an Intel card would be)</comment>
299 &lt;M&gt; Intel/SiS/nVidia/AMD/ALi AC97 Controller
300 <comment>(Or if you have a VIA Card)</comment>
301 &lt;M&gt; VIA 82C686A/B, 8233/8235 AC97 Controller
302
303<comment>(Move one level back and select in case you have an USB sound card)</comment>
304USB Devices ---&gt;
305</pre>
306
307<p>
308Now that your options are set, you can (re)compile the kernel and ALSA support
309for your card should be functional once you reboot into the new kernel.
310You can now proceed to <uri link="#alsa-utilities">ALSA Utilities</uri> and
311see if everything is working as it should.
312</p>
313
314</body>
81<section> 315</section>
82 <title>What cards does ALSA support?</title> 316<section id="alsa-driver">
317<title>Using the ALSA Driver package</title>
83<body> 318<body>
84<p> 319
85ALSA tries to support as many (new) cards as possible by providing open-source drivers.
86However, some vendors may provide binary-only packages.
87</p> 320<p>
88<p>To know if your card is supported, you can find a Soundcard Matrix of supported and not-supported cards here: 321So you've decided to go the <c>alsa-driver</c> way. Let's get started then.
89<uri>http://www.alsa-project.org/alsa-doc/</uri>. 322There are a few minor things to be done to ensure only the drivers for your
323sound card are compiled. Although this is not really necessary, it cuts down
324on the unnecessary drivers that will be compiled otherwise.
325</p>
326
90</p> 327<p>
328If you don't have an idea of what drivers your sound card might need, please
329take a look at the <uri link="#lspci">lspci</uri> section of this guide. Once
330you have your driver name (<c>emu10k1</c> in our example), edit
331<path>/etc/make.conf</path> and add a variable, <c>ALSA_CARDS</c>.
332</p>
333
334<pre caption="Adding ALSA_CARDS to make.conf">
335<comment>(For one sound card)</comment>
336ALSA_CARDS="emu10k1"
337<comment>(For more than one, seperate names with spaces)</comment>
338ALSA_CARDS="emu10k1 via82xx"
339</pre>
340
341<p>
342If you have compiled your kernel and want to use <c>alsa-driver</c>, please
343ensure the following before proceeding, else <c>alsa-driver</c> is likely to
344fail. The next code listing gives you one way of performing the checks.
345</p>
346
347<note>
348<c>genkernel</c> users can proceed with <uri link="#doc_chap2_pre6">Installing
349alsa-driver</uri> as their configuration is in sync with the one shown below by
350default.
351</note>
352
353<ol>
354 <li>
355 <c>CONFIG_SOUND</c> is set. (Basic Sound support enabled)
356 </li>
357 <li>
358 <c>CONFIG_SOUND_PRIME</c> is not set. (In-built OSS support disabled)
359 </li>
360 <li>
361 <c>CONFIG_SND</c> is not set. (In-built ALSA support disabled)
362 </li>
363 <li>
364 <path>/usr/src/linux</path> points to the kernel you want ALSA working on.
365 </li>
366</ol>
367
368<pre caption=".config checks">
369<comment>(Assuming the linux symlink points to the correct kernel)</comment>
370# <i>cd /usr/src/linux</i>
371# <i>grep SOUND .config</i>
372<comment>(1. is true)</comment>
373CONFIG_SOUND=y
374<comment>(2. is true)</comment>
375CONFIG_SOUND_PRIME is not set
376# <i>grep SND .config</i>
377<comment>(and 3. is true)</comment>
378CONFIG_SND is not set
379</pre>
380
381<p>
382Now all you have to do is type the magic words... and no, it's not abracadabra.
383</p>
384
385<pre caption="Installing alsa-driver">
386# <i>emerge alsa-driver</i>
387</pre>
388
389<impo>
390Please note that you will have to run <c>emerge alsa-driver</c> after every
391kernel (re)compile, as the earlier drivers are deleted.
392</impo>
393
91</body> 394</body>
92</section> 395</section>
93</chapter> 396</chapter>
94 397
95<chapter> 398<chapter>
96<title>Installation</title> 399<title>Configuring/Testing ALSA</title>
97<section> 400<section id="alsa-utilities">
98<title>Gentoo USE flags</title> 401<title>ALSA Utilities</title>
99<body>
100
101<p>
102To compile programs with ALSA-support, be sure to add <e>alsa</e> to
103your USE-variable. However, several tools don't support alsa yet, and
104require OSS. ALSA provides OSS-emulation if you define <e>oss</e> in your
105USE-variable before you start.
106</p>
107
108</body> 402<body>
109</section>
110 403
111<section>
112 <title>Kernel modules</title>
113<body>
114<p>
115Since we're still using 2.4.x kernel sources, we'll have to compile kernel modules and ALSA modules separately. People who are using a 2.5.x kernel can do this from within their kernel configuration, since the ALSA modules are included in the kernel sources and should be built there.
116</p> 404<p>
405<c>alsa-utils</c> forms an integral part of ALSA as it has a truckload of
406programs that are highly useful, including the ALSA Initscripts. Hence we
407strongly recommend that you install <c>alsa-utils</c>
117<p> 408</p>
118First we'll make sure that our kernel configuration is ready for use with ALSA. 409
119All you need in your kernel configuration is having Sound Card Support set to be built as a module (M). 410<pre caption="Install alsa-utils">
120This will build <c>soundcore.o</c>. 411# <i>emerge alsa-utils</i>
121</p> 412</pre>
122<p> 413
123<note> 414<note>
124Possibly, this will also work when you built Sound Card Support in the kernel (Y) instead of building it as a module (M). 415If you activated ALSA in your <uri link="#kernel">kernel</uri> <e>and</e> did
125However, the official ALSA documentation suggests building it as a module, since ALSA will try loading it. 416not compile ALSA as modules, please proceed to the
417<uri link="#initscript">ALSA Initscript</uri> section. The rest of you need
418to configure ALSA. This is made very easy by the existence of the
419<c>alsaconf</c> tool provided by <c>alsa-utils</c>.
126</note> 420</note>
421
422</body>
423</section>
424<section id="alsa-config">
425<title>Configuration</title>
426<body>
427
428<note>
429Please shut down any programs that <e>might</e> access the sound card while
430running <c>alsaconf</c>.
431</note>
432
127</p> 433<p>
128<p>If you already have a working kernel configuration, make sure you remove all sound drivers (except for Sound Card Support). 434The easiest way to configure your sound card is to run <c>alsaconf</c>. Just
129If you wish to do this without having to reboot, you could do like this: 435type <c>alsaconf</c> in a shell as root.
130</p> 436</p>
437
438<pre caption="Invoking alsaconf">
439# <i>alsaconf</i>
131<pre> 440</pre>
132# <i>cd /usr/src/linux</i> 441
133# <i>cp .config ~/</i>
134# <i>make mrproper</i>
135# <i>cp ~/.config .</i>
136# <i>make menuconfig</i>
137</pre>
138<p>
139Now select <e>Sound Card Support</e> as Module (M) and deselect all other sound drivers.
140Exit and say Y to save your kernel configuration.
141After that, build the modules:
142</p> 442<p>
443You will now see a neat menu guided interface that will automatically probe
444your devices and try to find out your sound card. You will be asked to pick
445your sound card from a list. Once that's done, it will ask you permission to
446automatically make required changes to <path>/etc/modules.d/alsa</path>.
447It will then adjust your volume settings to optimum levels, run
448<c>modules-update</c> and start the <path>/etc/init.d/alsasound</path> service.
449Once <c>alsaconf</c> exits, you can proceed with setting up the ALSA initscript.
450</p>
451
452</body>
453</section>
454<section id="initscript">
455<title>ALSA Initscript</title>
456<body>
457
458<p>
459We're now almost all setup. Whichever method you chose to install ALSA, you'll
460need to have something load your modules or initialize ALSA and restore your
461volume settings when your system comes up. The ALSA Initscript handles all of
462this for you and is called <c>alsasound</c>. Add it to the boot runlevel.
463</p>
464
465<pre caption="Adding ALSA to the boot runlevel">
466# <i>rc-update add alsasound boot</i>
467 * alsasound added to runlevel boot
468 * rc-update complete.
143<pre> 469</pre>
144# <i>make dep clean</i> 470
145# <i>make modules modules_install</i>
146</pre>
147<p>
148Before installing your new modules, this last line will delete all your previous modules,
149even the ones from a previous ALSA installation.
150</p> 471<p>
472Next, just check the <path>/etc/conf.d/alsasound</path> file and ensure that
473SAVE_ON_STOP variable is set to yes. This saves your sound settings when you
474shutdown your system.
151<p> 475</p>
476
477</body>
478</section>
479<section>
480<title>Audio Group</title>
481<body>
482
483<p>
484Before we move on to testing, there's one last <e>important</e> thing that needs
485to be setup. Rule of thumb in a *nix OS : Do not run as root unless needed.
486This applies here as well ;) How? Well, most of the times you should be logged
487in as a user and would like to listen to music or access your soundcard. For
488that to happen, you need to be in the "audio" group. At this point, we'll add
489users to the audio group, so that they won't have any issues when they want to
490access sound devices. We'll use <c>gpasswd</c> here and you need to be logged in
491as root for this to work.
492</p>
493
494<pre caption="Adding users to the audio group">
495<comment>(Substitute &lt;username&gt; with your user)</comment>
496# <i>gpasswd -a &lt;username&gt; audio </i>
497Adding user &lt;username&gt; to group audio
498</pre>
499
500</body>
501</section>
502<section>
503<title>Volume Check!</title>
504<body>
505
506<p>
507We've completed all the setups and pre-requisites, so let's fire up ALSA. If
508you ran <c>alsaconf</c>, you can skip this step, since <c>alsaconf</c> already
509does this for you.
510</p>
511
512<pre caption="Start the service">
513<comment>(ALSA as modules)</comment>
514# <i>/etc/init.d/alsasound start</i>
515 * Loading ALSA modules ...
516 * Loading: snd-card-0 ... [ ok ]
517 * Loading: snd-pcm-oss ... [ ok ]
518 * Loading: snd-seq ... [ ok ]
519 * Loading: snd-emu10k1-synth ... [ ok ]
520 * Loading: snd-seq-midi ... [ ok ]
521 * Restoring Mixer Levels ... [ ok ]
522<comment>(ALSA compiled in)</comment>
523# <i>/etc/init.d/alsasound start</i>
524 * Loading ALSA modules ...
525 * Restoring Mixer Levels ... [ ok ]
526</pre>
527
528<p>
529Now that the required things have been taken care of, we need to check up on
530the volume as in certain cases, it is muted. We use <c>alsamixer</c> for this
531purpose.
532</p>
533
534<pre caption="Starting alsamixer">
535<comment>(Opens up a console program. Only required settings are shown)</comment>
536# <i>alsamixer</i>
537</pre>
538
152<impo> 539<impo>
153This means, whenever you recompile your kernel later on, you MUST recompile <c>alsa-driver</c>. 540If you have issues starting up <c>alsamixer</c> and get errors such as
541alsamixer: function snd_ctl_open failed for default: No such file or directory,
542this is usually an issue with udev setting up the devices. Run <c>killall -9
543udevd; udevstart</c> to reload /dev entries and fire up <c>alsamixer</c>. It
544should solve the issue.
154</impo> 545</impo>
546
155</p> 547<p>
548This is how the ALSA Mixer <e>might</e> look the first time you open it. Pay
549attention to the Master and PCM channels which both have an MM below them.
550That means they are muted. If you try to play anything with <c>alsamixer</c>
551in this state, you will not hear anything on your speakers.
156<p> 552</p>
157<note>However, there's no need to reinstall <c>nvidia-kernel</c>, the Nvidia drivers are in a separate directory 553
158in <path>/lib/modules/*/video</path> and won't get deleted by a <c>make modules modules_install</c> 554<figure link="/images/docs/alsa-mixermuted.png" short="AlsaMixer Muted" caption="The Alsa Mixer Main Window, Muted"/>
555
556<p>
557Now, we shall unmute the channels, and set volume levels as needed.
558</p>
559
560<warn>
561Both Master <e>and</e> PCM need to be unmuted and set to audible volume levels
562if you want to hear some output on your speakers.
563</warn>
564
565<ul>
566 <li>
567 To move between channels, use your left and right arrow keys. (&lt;-
568 &amp; -&gt;)
569 </li>
570 <li>
571 To toggle mute, move to the specific channel, for example Master and press
572 the <e>m</e> key on the keyboard.
573 </li>
574 <li>
575 To increase and decrease the volume levels, use the up and down arrow keys
576 respectively.
577 </li>
578</ul>
579
580<note>
581Be careful when setting your Bass and Treble values. 50 is usually a good
582number for both. Extremely high values of Bass may cause <e>jarring</e>
583on speakers that are not designed to handle them.
159</note> 584</note>
585
160</p> 586<p>
161</body> 587After you're all done, your ALSA Mixer should look similar to the one below.
162</section> 588Note the 00 instead of the MM and also the volume levels for some optimum
589settings.
590</p>
163 591
592<figure link="/images/docs/alsa-mixerunmuted.png" short="AlsaMixer Unmuted" caption="Alsa Mixer ready to roll"/>
593
594</body>
164<section> 595</section>
165 <title>ALSA modules</title> 596<section>
597<title>Sound Check!</title>
166<body> 598<body>
167 599
168<p>
169Now it's time to install the ALSA drivers for your soundcard(s). If your soundcard is PCI, you can find out the name
170and type of your soundcard by looking at the output of /proc/pci.
171</p> 600<p>
601The irritating way to check your soundcard is to see if you can hear static on
602the speakers. This isn't exactly fun, but hey, it tells you the card is
603configured and working.
604</p>
605
606<pre caption="Bring on th static">
607# <i>cat /dev/urandom > /dev/dsp</i>
172<pre> 608</pre>
173# <i>grep audio /proc/pci</i>
174</pre>
175 609
176
177<p>
178<warn>
179If you had a previous sound setup and there are still non-ALSA sound modules loaded, unload them <e>now</e>.
180Check with <c>lsmod</c> and use <c>rmmod</c> to unload all sound-related modules on your system.
181</warn>
182</p>
183
184<p>
185We could simply do an <c>emerge alsa-driver</c> now, this would compile and install <e>all</e> ALSA sound drivers.
186</p>
187<p>
188However, to save some time, lookup the <e>Module Name</e> of your soundcard(s) on the
189<uri link="http://www.alsa-project.org/alsa-doc">ALSA Soundcard Matrix</uri> by following the <e>Details</e> link in the <e>Driver and Docs</e> column in the row of the chipset of your soundcard.
190Mine is <c>snd-emu10k1</c>, since I have an SBlive! soundcard, with the <e>EMU10K1</e> chipset.
191We'll set ALSA_CARDS environment to the value of the module name before emerging (but without the snd prefix), so emerge will only compile the drivers we need.
192</p>
193
194<pre>
195# <i>env ALSA_CARDS='emu10k1' emerge alsa-driver</i>
196</pre>
197<note> 610<note>
198You can also add this value in <path>/etc/make.conf</path>, so when you have to emerge the alsa-driver later on you can just run <c>emerge alsa-driver</c>. 611<path>/dev/dsp</path> is a symlink to <path>/dev/sound/dsp</path> and should be
199For example, like this: <c>echo 'ALSA_CARDS="emu10k1"' >> /etc/make.conf</c> 612automatically created. Try re-directing the output to
613<path>/dev/sound/dsp</path> in case you don't get a "No such file or directory"
614error.
200</note> 615</note>
201 616
617<p>
618You should hear static. Press <c>Ctrl + C</c> to stop. If you don't hear
619anything, now is a good time to go back and check/trace out the issue and
620rectify it.
621</p>
622
623<p>
624Finally. Some music. If everything above is perfect, you should now be able to
625listen to some good music. A quick way to test is to use a command line tool
626like <c>media-sound/madplay</c>. You could also use something more well known
627like <c>mpg123</c> or <c>xmms</c>. If you are an ogg fan, you could use
628<c>ogg123</c> provided by <c>media-sound/vorbis-tools</c>. Use any player you
629are comfortable with. As always, <c>emerge</c> what you need.
630</p>
631
632<pre caption="Getting the software">
633<comment>(Install the applications you want)</comment>
634# <i>emerge madplay mpg123 xmms</i>
635<comment>(To play .ogg files)</comment>
636# <i>emerge vorbis-tools</i>
637</pre>
638
639<p>
640And then play your favorite sound track...
641</p>
642
643<pre caption="Playing Music">
644# <i>madplay -v /mnt/shyam/Music/Paul\ Oakenfold\ -\ Dread\ Rock.mp3</i>
645MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
646 Title: Dread Rock
647 Artist: Paul Oakenfold
648 Album: Matrix Reloaded
649 Year: 2003
650 Genre: Soundtrack
651 Soundtrack
652 00:04:19 Layer III, 160 kbps, 44100 Hz, joint stereo (MS), no CRC
653
654# <i>ogg123 Paul\ Oakenfold\ -\ Dread\ Rock.ogg</i>
655Audio Device: Advanced Linux Sound Architecture (ALSA) output
656
657Playing: Paul Oakenfold - Dread Rock.ogg
658Ogg Vorbis stream: 2 channel, 44100 Hz
659Genre: Soundtrack
660Transcoded: mp3;160
661Title: Dread Rock
662Artist: Paul Oakenfold
663Date: 2003
664Album: Matrix Reloaded
665Time: 00:11.31 [04:28.75] of 04:40.06 (200.6 kbps) Output Buffer 96.9%
666</pre>
667
668</body>
669</section>
670<section>
671<title> ALSA and USE</title>
672<body>
673
674<p>
675You can now add the <c>alsa</c> use flag to <path>/etc/make.conf</path> to
676ensure that your applications that support ALSA get built with it. Some
677architectures like x86 and amd64 have the flag enabled by default.
678</p>
679
680</body>
681</section>
682<section>
683<title>Issues?</title>
684<body>
685
686<p>
687If for some reason you're unable to hear sound, the first thing to do would
688be to check your <uri link="#doc_chap3_pre6">alsamixer</uri> settings. 80% of
689the issues lie with muted channels or low volume. Also check your Window
690Manager's sound applet and verify that volumes are set to audible levels.
691</p>
692
693<p>
694<path>/proc</path> is your friend. And in this case, <path>/proc/asound</path>
695is your best friend. We shall just take a short look at how much info is made
696available to us there.
697</p>
698
699<pre caption="Fun with /proc/asound">
700<comment>(First and foremost, if /proc/asound/cards shows your card, ALSA has
701picked up your sound card fine.)</comment>
702# <i>cat /proc/asound/cards</i>
7030 [Live ]: EMU10K1 - Sound Blaster Live!
704 Sound Blaster Live! (rev.6, serial:0x80271102) at 0xb800, irq 11
705
706<comment>(If you run ALSA off the kernel like I do and wonder how far behind
707you are from alsa-driver, this displays current running ALSA version)</comment>
708# <i>cat /proc/asound/version</i>
709Advanced Linux Sound Architecture Driver Version 1.0.8 (Thu Jan 13 09:39:32 2005 UTC).
710
711<comment>(ALSA OSS emulation details)</comment>
712# <i>cat /proc/asound/oss/sndstat</i>
713Sound Driver:3.8.1a-980706 (ALSA v1.0.8 emulation code)
714Kernel: Linux airwolf.zion 2.6.11ac1 #2 Wed May 4 00:35:08 IST 2005 i686
715Config options: 0
716
717Installed drivers:
718Type 10: ALSA emulation
719
720Card config:
721Sound Blaster Live! (rev.6, serial:0x80271102) at 0xb800, irq 11
722
723Audio devices:
7240: EMU10K1 (DUPLEX)
725
726Synth devices: NOT ENABLED IN CONFIG
727
728Midi devices:
7290: EMU10K1 MPU-401 (UART)
730
731Timers:
7327: system timer
733
734Mixers:
7350: SigmaTel STAC9721/23
736</pre>
737
738</body>
739</section>
740</chapter>
741
742<chapter>
743<title>Other things ALSA</title>
744<section>
745<title>Setting up MIDI support</title>
746<body>
747
748<p>
749If your sound card is one of those that come with on-board MIDI synthesizers
750and you would like to listen to some .mid files, you have to install
751<c>awesfx</c> which is basically a set of utilities for controlling the AWE32
752driver. We need to install it first. If you don't have a hardware synthesizer,
753you can use a virtual one. Please see the section on
754<uri link="#vsynth">Virtual Synthesizers</uri> for more information.
755</p>
756
757<pre caption="Installing awesfx">
758# <i>emerge awesfx</i>
759</pre>
760
202<note> 761<note>
203When you want to install ALSA drivers for more than one soundcard, you could set ALSA_CARDS to a space-separated list 762You will need to copy over SoundFont (SF2) files from your sound card's driver
204of drivers; like this: <c>env ALSA_CARDS='emu10k1 intel8x0 ens1370' emerge alsa-driver</c> 763CD or a Windows installation into <path>/usr/share/sounds/sf2/</path>. For
764example a sound font file for the Creative SBLive! card would be 8MBGMSFX.SF2.
205</note> 765</note>
206 766
207<note>If you want to have OSS compatibility, make sure to emerge <i>alsa-oss</i>, it is the ALSA/OSS compatibility
208wrapper. </note>
209
210<note>If you plan on recompiling your kernels numerous times, it might
211be adviseable to emerge <c>alsa-driver</c> with <c>--buildpkg</c>. This
212will create a binary package for it. Later, after recompiling your kernel,
213you can just do <c>emerge --usepkg alsa-driver</c> which will install the
214binary package instead of recompiling it completely.</note>
215
216<p>
217After this, the ALSA modules should be installed on your system.
218</p> 767<p>
219</body> 768After copying over the Soundfont files, we can then play a midi file as shown.
220</section> 769You can also add the <c>asfxload</c> command to
221<section> 770<path>/etc/conf.d/local.start</path>, so that the sound font is loaded
222 <title>Configuration of ALSA</title> 771every time the system starts up.
223<body>
224<p> 772</p>
225Let's start configuring now to get ALSA working properly.
226We'll need to edit some files, to let our system know about the freshly installed ALSA modules.
227</p>
228 773
229<p>
230First, install <c>alsa-utils</c> on your system:
231</p>
232
233<pre caption = "Emerging alsa-utils">
234# <i>emerge alsa-utils</i>
235</pre>
236
237<p>
238Hereafter, we need to edit <path>/etc/modules.d/alsa</path>.
239</p>
240<warn>
241There is no need to edit <path>/etc/modules.conf</path>. Instead, always edit files in <path>/etc/modules.d</path>.
242</warn>
243<p>
244Check the ALSA portion <e>at the bottom of the file</e>.
245By tweaking this line you can specify the max number of soundcards you have (generally, just one).
246</p>
247<pre caption="At the bottom of /etc/modules.d/alsa">
248<comment>Set this to the correct number of cards.</comment>
249options snd cards_limit=1
250</pre>
251<p>
252Now we'll specify the sounddriver(s) ALSA should use. In the same file, edit like this:
253</p>
254<pre caption="In /etc/modules.d/alsa">
255## and then run `modules-update' command.
256## Read alsa-driver's INSTALL file in /usr/share/doc for more info.
257##
258## ALSA portion
259alias snd-card-0 snd-emu10k1
260<comment>## If you have more than one, add:</comment>
261## alias snd-card-1 snd-intel8x0
262## alias snd-card-2 snd-ens1370
263## OSS/Free portion
264## alias sound-slot-0 snd-card-0
265## alias sound-slot-1 snd-card-1
266##
267</pre>
268<note> 774<note>
269If you have more than one soundcard, adjust the <c>cards_limit</c> value and add more snd-card aliases to the file. 775<path>/mnt</path> paths mentioned in the code listing(s) below will <e>not</e>
270I don't have experience with this, but you can find examples for configurations with two or more soundcards in 776be the same in your machine. They are just an example. Please be careful to
271<uri link="http://www.alsa-project.org/alsa-doc/alsa-howto/c1660.htm">Chapter 6</uri> 777change the path to suit your machine.
272of the <uri link="http://www.alsa-project.org/alsa-doc/alsa-howto/alsa-howto.html">ALSA Howto</uri>.
273</note> 778</note>
274<p> 779
275Last thing to do in this file, almost at the end, check if these lines are there and uncommented: 780<pre caption="Loading Soundfonts">
276</p> 781<comment>(First, copy the Soundfont)</comment>
277<pre caption="Near the end of /etc/modules.d/alsa"> 782# <i>cp /mnt/win2k/Program\ Files/CreativeSBLive2k/SFBank/8MBGMSFX.SF2 /usr/share/sounds/sf2/</i>
278alias /dev/mixer snd-mixer-oss 783<comment>(We load the specific Soundfont)</comment>
279alias /dev/dsp snd-pcm-oss 784# <i>asfxload /usr/share/sounds/sf2/8MBGMSFX.SF2</i>
280alias /dev/midi snd-seq-oss
281</pre>
282<p>
283Now double-check the file <path>/etc/modules.d/alsa</path> and when you're sure everyting is ok, run <c>modules-update</c>.
284<pre> 785</pre>
285# <i>modules-update</i> 786
286</pre>
287</p> 787<p>
288<note> 788You can now play midi files using a program like <c>aplaymidi</c>. Run
289Running <c>modules-update</c> here will insert the data from <path>/etc/modules.d/alsa</path> into <path>/etc/modules.conf</path> 789<c>aplaymidi -l</c> to get a list of available ports and then pick one
290</note> 790to play the file on.
291<p> 791</p>
292You should also verify that /etc/devfsd.conf has the alsa devices and permissions correctly registered. 792
793<pre caption="Playing MIDI">
794<comment>(Check open ports)</comment>
795# <i>aplaymidi -l</i>
796 Port Client name Port name
797 64:0 EMU10K1 MPU-401 (UART) EMU10K1 MPU-401 (UART)
798 65:0 Emu10k1 WaveTable Emu10k1 Port 0
799 65:1 Emu10k1 WaveTable Emu10k1 Port 1
800 65:2 Emu10k1 WaveTable Emu10k1 Port 2
801 65:3 Emu10k1 WaveTable Emu10k1 Port 3
802<comment>(Pick a port, and play a mid file)</comment>
803# <i> aplaymidi --port=65:0 /mnt/shyam/music/midi/mi2.mid</i>
293</p> 804</pre>
294<pre caption="/etc/devfsd.conf"> 805
295# ALSA/OSS stuff
296# Comment/change these if you want to change the permissions on
297# the audio devices
298LOOKUP snd MODLOAD ACTION snd
299LOOKUP dsp MODLOAD
300LOOKUP mixer MODLOAD
301LOOKUP midi MODLOAD
302REGISTER sound/.* PERMISSIONS root.audio 660
303REGISTER snd/.* PERMISSIONS root.audio 660
304</pre>
305<note>
306Notice that devfsd.conf sets /dev/sound permissions to be root.audio. Thus, for non-root users to use audio they will have to be part of the audio group.
307</note>
308</body> 806</body>
309</section>
310</chapter>
311<chapter>
312<title>Starting ALSA</title>
313<section> 807</section>
314 <title>Adding alsasound to a runlevel</title> 808<section id="vsynth">
315<body> 809<title>Virtual Synthesizers</title>
316<p>
317First thing to do now, is to make ALSA startup at boottime. Like this:
318<pre>
319# <i>rc-update add alsasound boot</i>
320</pre>
321</p>
322<p>
323<warn>Note that the alsasound script should be added to the "boot" runlevel, not the "default" runlevel.</warn>
324</p>
325</body> 810<body>
326</section> 811
812<p>
813If your sound card lacks a hardware synthesizer, you could use a virtual one
814like <c>timidity++</c>. Installation is a breeze.
815</p>
816
817<pre caption="Installing timidity++">
818# <i>emerge timidity++</i>
819</pre>
820
821<p>
822For timidity to play sounds, it needs a sound font. If you do not have any,
823install <c>timidity-eawpatches</c> or <c>timidity-shompatches</c> which will
824give you some sound fonts. You can have multiple sound font configurations
825installed, and you can place your own in <path>/usr/share/timidity/</path>.
826To switch between different timidity configurations, you should use the
827<c>timidity-update</c> tool provided in the timidity++ package.
828</p>
829
830<pre caption="Installing sound fonts">
831# <i>emerge timidity-eawpatches</i>
832# <i>timidity-update -g -s eawpatches</i>
833
834<comment>(or)</comment>
835
836# <i>emerge timidity-shompatches</i>
837# <i>timidity-update -g -s shompatches</i>
838</pre>
839
840<p>
841Don't forget to add <c>timidity</c> to the default runlevel.
842</p>
843
844<pre caption="Adding timidity to the default runlevel">
845# <i>rc-update add timidity default</i>
846# <i>/etc/init.d/timidity start</i>
847</pre>
848
849<p>
850You can now try out <uri link="#doc_chap4_pre3">Playing MIDI</uri> files.
851</p>
852
853</body>
327<section> 854</section>
328 <title>Running and unmuting</title>
329<body>
330<p>
331Since we're Linux users, we don't want to reboot. So we'll start the alsasound script manually.
332</p>
333<pre>
334# <i>/etc/init.d/alsasound start</i>
335</pre>
336<p>
337ALSA is running now. If everything is ok, you should be able to see the ALSA modules loaded when running <c>lsmod</c>.
338However, sound won't work yet, because the channels are still muted. We need <c>amixer</c> for this.
339</p>
340<pre caption = "Running amixer">
341# <i>amixer</i>
342</pre>
343<p>
344<warn>
345You shouldn't get this, but <e>if</e> you get an error about "amixer: Mixer attach default error: No such file or directory", you should manually modprobe
346<c>snd-mixer-oss</c> and <c>snd-pcm-oss</c> once. After that run amixer again.
347</warn>
348</p>
349<pre caption="only if you get an error when running amixer">
350# <i>modprobe snd-mixer-oss</i>
351# <i>modprobe snd-pcm-oss</i>
352# <i>amixer</i>
353</pre>
354<p>
355If you got this far, now unmute Master and PCM channels. Some hardware
356even requires you to unmute the center channel or even the surround
357channel.
358</p>
359<p>
360<pre caption = "Unmuting channels">
361# <i>amixer set Master 100 unmute</i>
362# <i>amixer set PCM 100 unmute</i>
363<comment>Only if the above doesn't succeed on its own:</comment>
364# <i>amixer set Center 100 unmute</i>
365# <i>amixer set Surround 100 unmute</i>
366<comment>Test the sound:</comment>
367# <i>aplay $KDEDIR/share/sounds/pop.wav</i> <codenote>(pop.wav is part of KDE)</codenote>
368</pre>
369</p>
370We check to see if sound is working by using the aplay (alsa play) command. If you hear a pop, then sound is indeed working.
371Then, adjust the volume settings to your liking; the ncurses-based <c>alsamixer</c> is a great way to get them "just so".
372<p>
373You may want to emerge <c>alsa-xmms</c> as that will provide ALSA support for XMMS.
374</p>
375When you reboot your system, the <e>alsasound</e> init script will properly save and restore your volume settings.
376</body>
377</section> 855<section>
378</chapter> 856<title>Tools and Firmware</title>
379<chapter> 857<body>
380<title>Final Notes</title> 858
859<p>
860Some specific sound cards can benefit from certain tools provided by the
861<c>alsa-tools</c> and <c>alsa-firmware</c> packages. If you need
862<c>alsa-tools</c>, be sure to define the ALSA_TOOLS variable in
863<path>/etc/make.conf</path> with the tools you require. For instance:
864</p>
865
866<pre caption="Selecting ALSA Tools in /etc/make.conf">
867ALSA_TOOLS="as10k1 ac3dec"
868</pre>
869
870<p>
871If the ALSA_TOOLS variable is not set, all available tools will be built.
872Now, install the <c>alsa-tools</c> (and/or <c>alsa-firmware</c>) package(s):
873</p>
874
875<pre caption="Installing ALSA Tools">
876# <i>emerge alsa-tools</i>
877</pre>
878
879</body>
381<section> 880</section>
382 <title>After kernel-upgrades..</title>
383<body>
384<p>When you ever rebuild your kernel, or upgrade to another kernel, you'll have to rebuild the ALSA modules.</p>
385<p>Although you might have installed <c>alsa-driver</c>, <c>alsa-libs</c> and <c>alsa-utils</c>, only the first will
386have to be installed again, since it will put the alsa modules in
387<path>/lib/modules/*/kernel/sound/pci/</path>.</p>
388<pre caption="needed after each kernel compile">
389# <i>emerge alsa-driver</i>
390</pre>
391</body>
392</section> 881<section>
882<title>A Big thank you to...</title>
883<body>
884
885<p>
886Everyone who contributed to the earlier version of the Gentoo ALSA Guide:
887Vincent Verleye, Grant Goodyear, Arcady Genkin, Jeremy Huddleston,
888John P. Davis, Sven Vermeulen, Benny Chuang, Tiemo Kieft and Erwin.
889</p>
890
891</body>
393<section> 892</section>
394 <title>/etc/modules.autoload</title>
395<body>
396<p>You won't have to edit this file for use with ALSA. After our <c>rc-update add alsasound boot</c>, our system will
397load the correct modules at startup.</p>
398<p>It's not necessary to add <c>snd-pcm-oss</c> or <c>snd-mixer-oss</c> in this file.
399Check the <uri link="http://www.djcj.org/LAU/guide/alsbook/faq1.html">this FAQ</uri> for more info.</p>
400</body>
401</section> 893<section>
402 894<title>References</title>
403<section>
404<title>Known bugs</title>
405<body> 895<body>
406
407<note>
408This guide lags behind on the alsa-development. Chances are these bugs
409are already fixed when you read this.
410</note>
411 896
412<ul> 897<ul>
413<li> 898 <li><uri link="http://www.alsa-project.org/">The ALSA Project</uri></li>
414If you have <b>lots of noise</b> when using <b>oss</b> emulation, add 899 <li><uri link="http://linux-sound.org">Linux Sound/MIDI Software</uri></li>
415<e>options snd-pcm-oss dsp_map=1</e> to
416<path>/etc/modules.d/alsa</path>.
417</li>
418</ul> 900</ul>
419 901
420</body>
421</section>
422
423<section>
424 <title>More links..</title>
425<body>
426<p>
427You could check these for additional info:
428</p>
429<p>
430<ul>
431<li><uri link="http://www.gentoo.org/doc/en/desktop.xml">The Gentoo Linux Desktop Configuration Guide</uri></li>
432<li><uri link="http://www.alsa-project.org">ALSA Project Homepage</uri></li>
433<li><uri link="http://www.alsa-project.org/documentation.php3">ALSA Users Documentation</uri></li>
434<li><uri link="http://www.djcj.org">ALSA Howto's and FAQ's</uri></li>
435<li><uri link="http://tldp.org/HOWTO/Sound-HOWTO/index.html">Linux Sound HOWTO</uri></li>
436<li><uri link="http://linux-sound.org/">Sound and MIDI Software For Linux</uri></li>
437</ul>
438</p>
439</body> 902</body>
440</section> 903</section>
441</chapter> 904</chapter>
442</guide> 905</guide>

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.56

  ViewVC Help
Powered by ViewVC 1.1.20