old-www/HOWTO/Linux-Gamers-HOWTO/x696.html

480 lines
13 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Sound</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The Linux Gamers' HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Video Cards"
HREF="x608.html"><LINK
REL="NEXT"
TITLE="Miscellaneous Problems"
HREF="x762.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Linux Gamers' HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x608.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x762.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN696"
></A
>8. Sound</H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN698"
></A
>8.1. Which sound card is best?</H2
><P
>By the word "best" I mean best for gaming. Gamers want high quality sound for our games
with the least amount of tinkering. On the other hand, a musician would have a very different
concept of what "best sound card" would mean. If you're a musician, you might want to check
out the <A
HREF="http://www.linuxdj.com/audio/quality/"
TARGET="_top"
>Linux Audio Quality
HOWTO</A
>.</P
><P
>Now that Linux is beginning to mature, this question isn't as important as it used to
be. Once upon a time, soundcards without onboard MIDI chips (most PCI sound cards) didn't do
MIDI. This was mostly a problem for things like xdoom or lxdoom using musserv. These days we
have MIDI emulators like Timidity and libraries like SDL which don't require hardware MIDI
support. Frankly, I've had many cards and I can't tell the difference between any of them for
gaming. If you want to do things like convert a record LP to digital format, then your choice
of a soundcard with a professional grade A/D converter is absolutely crucial. For this HOWTO,
we'll assume that you're more of a gamer than a studio recording engineer.</P
><P
>Your decision should be based on what will be the easiest to configure. If you already
have a card and it works well, that's good enough. If you're in the market to buy a sound
card, get something that will take you a second to configure. PCI cards are much easier to
deal with than ISA since you don't need to tell their drivers about which system resources
(IRQ, DMA, I/O addresses) to use. Some ISA cards ARE plug-n-play, like the Creative AWE-64,
and the Linux kernel has come a long way in auto configuring them.</P
><P
>My personal recommendation is any card which has the es1370 or es1371 chip, which uses
the es1370 and es1371 sound drivers on Linux. These cards include the older Ensoniq es1370
and newer Creative PCI-128. These cards are extremely cheap and trivial to get working under
Linux.</P
><P
>I used to be a fan of the Creative Soundblaster AWE 32, AWE 64 and AWE 64 gold
soundcards. These ISA PnP cards are well supported by both OSS and Alsa. They all use the
same E-mu 8000 synthesis chip which enables them to play 32 voices simultaneously (they have
32 "channels"). A few notes: First, the Soundblaster AWE HOWTO is very out of date. Second,
the AWE 64 and AWE 64 gold can play 64 voices simultaneously, but this is done in software.
Creative never released a Linux driver for these cards (and they never released programming
information to Linux developers), so Linux users cannot use the extra 32 channels on the AWE
64 and AWE 64 gold. As far Linux users are concerned, all three cards are completely
identical (although the AWE 64 gold has gold plated connectors, which are better for sound
quality than the more common steel connectors).</P
><P
>The Creative Soundblaster Live! is an extremely popular PCI sound card these days. I've
never owned one, so I cannot comment here. However, there have been numerous reports about
serious problems with the Live! and AMD motherboards that use the 686b southbridge. A google
search should turn up alot of information on this problem.</P
><P
>A more relevent issue is speakers, but even here the difference isn't huge. I've had
expensive Altec Lansing speakers perform only slightly better than el-cheapo speakers. You
get what you pay for with speakers, but don't expect a huge difference. You'll want to get
something with a separate sub-woofer; this does make a difference at a cost of extra power and
connector wires.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN708"
></A
>8.2. Why isn't my sound working?</H2
><P
>First of all, it's probably not the game, it's probably your setup. AFAIK, there are 3
options to getting a sound card configured under Linux: the free OSS sound drivers that come
with the Linux kernel, the Alsa drivers and the commercial OSS sound drivers. Personally, I
prefer the free OSS drivers, but many people swear by Alsa. The commercial OSS drivers are
good when you're having trouble getting your sound card to work by free methods. Don't
discount them; they're very cheap (like 10 or 20 bucks), support bleeding edge sound cards and
take a lot of guesswork out of the configuring process.</P
><P
>There are 5 things that can go wrong with your sound system:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>Shared interrupt</P
></LI
><LI
><P
>Misconfigured driver</P
></LI
><LI
><P
>Something's already accessing the sound card</P
></LI
><LI
><P
>You're using the wrong driver</P
></LI
><LI
><P
>A permissions problem</P
></LI
></OL
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN723"
></A
>8.2.1. Shared interrupt</H3
><P
>The first thing to do is to figure out if you have an IRQ conflict. ISA cards can't
share interrupts. PCI cards can share interrupts, but certain types of high bandwidth
cards simply don't like to share, including network and sound cards. To find out whether
you have a conflict, do a <TT
CLASS="USERINPUT"
><B
>cat /proc/interrupts</B
></TT
>. Output on my
system is:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> $ cat /proc/interrupts
CPU0 CPU1
0: 24185341 0 XT-PIC timer
1: 224714 0 XT-PIC keyboard
2: 0 0 XT-PIC cascade
5: 2478476 0 XT-PIC soundblaster
5: 325924 0 XT-PIC eth0
11: 131326 0 XT-PIC aic7xxx
12: 2457456 0 XT-PIC PS/2 Mouse
14: 556955 0 XT-PIC ide0
NMI: 0 0
LOC: 24186046 24186026
ERR: 1353
</PRE
></FONT
></TD
></TR
></TABLE
><P
>The second column is there because I have 2 CPU's in this machine; if you have one
CPU (called UP, or uniprocessor), you'll have only 1 CPU column. The numbers on the left
are the assigned IRQ's and the strings to the right indicate what device was assigned that
IRQ. You can see I have an IRQ conflict between the soundcard (soundblaster) and the
network card (eth0). They both share IRQ 5. Actually, I cooked this example up because I
wanted to show you what an IRQ conflict looks like. But if I did have this conflict,
neither my network nor my sound would work well (or at all!).</P
><P
>If my sound card is PCI, the preferred way of fixing this would be to simply move
one of the cards to a different slot and hope the BIOS sorts things out. A more advanced
way of fixing this would be to go into BIOS and assign IRQ's to specific slots. Modern
BIOS'es can do this.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN730"
></A
>8.2.2. Misconfigured driver</H3
><P
>Sometimes, a card is hardwired to use a certain IRQ. You'll see this on ISA cards
only. Alternatively, some ISA cards can be set to use a specific IRQ using jumpers on the
card itself. With these types of cards, you need to pass the correct IRQ and memory
access, "I/O port", to the driver.</P
><P
>This is a sound card specific issue, and beyond the scope of this HOWTO.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN734"
></A
>8.2.3. Something is already accessing your sound card</H3
><P
>Perhaps an application is already accessing your soundcard. For example, maybe you
have an MP3 player that's paused? If something is already accessing your card, other
applications won't be able to. Even though it was written to share the card between
applications, I've found that esd (the enlightenment sound daemon) sometimes doesn't work
correctly. The best tool to use here is lsof, which shows which processes are accessing a
file. Your sound card is represented by <TT
CLASS="FILENAME"
>/dev/dsp</TT
>.
Right now, I'm listening to an MP3 (not a Metallica MP3, of course...) with
mp3blaster.</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> # lsof /dev/dsp
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mp3blaste 1108 p 6w CHR 14,3 662302 /dev/dsp
</PRE
></FONT
></TD
></TR
></TABLE
><P
><B
CLASS="COMMAND"
>fuser</B
> is similar; but it lets you send a signal to any process accessing the device
file.</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> # fuser -vk /dev/dsp
USER PID ACCESS COMMAND
/dev/dsp root 1225 f.... mp3blaster
root 1282 f.... mp3blaster
</PRE
></FONT
></TD
></TR
></TABLE
><P
>After issuing this command, mp3blaster was killed with SIGKILL. See the man pages
for lsof and fuser; they're very useful. Oh, you'll want to run them as root since you'll
be asking for information from processes that may be owned by root.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN743"
></A
>8.2.4. You're using the wrong driver (or no driver)</H3
><P
>There are only two ways to configure your card:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>Support must be compiled directly into the kernel</P
></LI
><LI
><P
>You must have the correct driver loaded into memory</P
></LI
></OL
><P
>You can find out which driver your sound card is using by doing "lsmod" or looking
at the output of "dmesg". Since sound is crucial for me, I always compile sound into my
kernels. If you don't have a driver loaded, you need to figure out what's been compiled
into your kernel. That's not so straight forward. Your best bet is to compile your
kernel. BTW, let me say that compiling your own kernel is the first step towards
proficiency with Linux. It's painful the first time you do it, but once you do it
correctly, it becomes very easy down the right, especially if you keep all your old
.config files and make use of things like "make oldconfig". See the Kernel HOWTO for
details.</P
><P
>If you haven't compiled the kernel yourself, there is an overwhelmingly good chance
that your system is set up to load sound drivers as modules. That's the way distros do
things. Have everything under the sun compiled as a module and try to load them all. So
if you don't see your sound card's driver with lsmod, your card probably isn't configured
yet.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN753"
></A
>8.2.5. Permissions Problem</H3
><P
>If the sound card works when you're root but not any other user, you probably have a
permissions problem. If this is the case, as root, look at the group owner of the sound
card using <TT
CLASS="USERINPUT"
><B
>ls -l /dev/dsp</B
></TT
>; it'll probably be
<TT
CLASS="LITERAL"
>audio</TT
>. Then, as root, add your non-root user to the audio group in
<TT
CLASS="FILENAME"
>/etc/group</TT
>. For example, I added the users p and wellspring to group
audio on my system:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> audio:x:29:p,wellspring
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Don't forget to use <B
CLASS="COMMAND"
>grpconv</B
> if you use shadow passwords
(which should be the case on most recent distributions) in order to maintain a consistent group
configuration. Then log out and log back in as the non-root user. Your sound card should work.
Thanks to James Barton for reminding me to add this to the howto.</P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x608.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x762.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Video Cards</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Miscellaneous Problems</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>