8. Sound

8.1. Which sound card is best?

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 Linux Audio Quality HOWTO.

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.

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.

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.

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).

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.

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.

8.2. Why isn't my sound working?

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.

There are 5 things that can go wrong with your sound system:

  1. Shared interrupt

  2. Misconfigured driver

  3. Something's already accessing the sound card

  4. You're using the wrong driver

  5. A permissions problem

8.2.1. Shared interrupt

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 cat /proc/interrupts. Output on my system is:

    $ 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

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!).

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.

8.2.2. Misconfigured driver

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.

This is a sound card specific issue, and beyond the scope of this HOWTO.

8.2.3. Something is already accessing your sound card

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 /dev/dsp. Right now, I'm listening to an MP3 (not a Metallica MP3, of course...) with mp3blaster.

    # lsof /dev/dsp
    mp3blaste 1108    p    6w   CHR   14,3      662302 /dev/dsp

fuser is similar; but it lets you send a signal to any process accessing the device file.

    # fuser -vk /dev/dsp
                         USER        PID ACCESS COMMAND
    /dev/dsp             root       1225 f....  mp3blaster
                         root       1282 f....  mp3blaster

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.

8.2.4. You're using the wrong driver (or no driver)

There are only two ways to configure your card:

  1. Support must be compiled directly into the kernel

  2. You must have the correct driver loaded into memory

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.

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.

8.2.5. Permissions Problem

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 ls -l /dev/dsp; it'll probably be audio. Then, as root, add your non-root user to the audio group in /etc/group. For example, I added the users p and wellspring to group audio on my system:


Don't forget to use grpconv 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.