个人工具

UbuntuHelp:SoundTroubleshooting

来自Ubuntu中文

跳转至: 导航, 搜索

<<Include(Tag/StyleCleanup)>>

Basic Troubleshooting Steps

Note: Most of these steps apply equally to Ubuntu, Kubuntu and Xubuntu. The core of all of these systems is the same, and sound is a "core" functionality.

Is your volume turned up, or is the speaker muted?

Double click on the "speaker" icon in the upper right hand corner of the screen. This will launch the Volume Control application, which has various sliders to control the volume. Make sure that the speaker, headphone and master sliders are not muted, and have the volume up from zero. On a fresh install of Ubuntu 8.10, the Speaker volume is turned all the way down. You can launch Gnome Volume Control application using Alt+<F2> and type

gnome-volume-control

Re-check the sliders.

Can you play a known-good sound?

aplay is part of the alsaplayer package, and Front_Center.wav is part of the alsa-utils package, so both are pretty standard. So try to run

aplay /usr/share/sounds/alsa/Front_Center.wav

in a terminal. You should hear a voice saying "Front" then "Center". If it doesn't play the first time you run that command, try running it again (it may not play the first time); you can also try running

aplay /usr/share/sounds/alsa/Front_Left.wav
aplay /usr/share/sounds/alsa/Front_Right.wav

Are you in the sound group?

Check that you are in the appropriate group. Depending on your ubuntu version, one of these commands should return something and the other should not:

fgrep -ie 'audio' /etc/group
fgrep -ie 'sound' /etc/group

E.g., with karmic, I got

$ fgrep -ie 'audio' /etc/group
> audio:x:29:pulse
$ fgrep -ie 'sound' /etc/group

so I backed up then changed /etc/group:

$ sudo cp /etc/group /etc/group_TODAYSDATE
$ sudo chmod a-wx /etc/group_TODAYSDATE
$ sudo adduser MY_USERNAME audio
$ fgrep -ie 'audio' /etc/group
> audio:x:29:pulse,MY_USERNAME

Is the system recognizing your sound card?

Open a terminal window, and type

sudo aplay -l

Your output should look something like this:

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC861VD Analog [ALC861VD Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

If you see aplay: device_list:221: no soundcard found..., Ubuntu is not recognizing your sound card for playback. Check that you have the proper modules installed.

Do you have the sound modules installed?

Open a terminal window, and type

find /lib/modules/`uname -r` | grep snd

You should see a whole list of items come up. If you don't, it means that the upgrade process missed installing the kernel modules for sound. To fix this, type this at the command line:

sudo aptitude install linux-ubuntu-modules-`uname -r` linux-generic

For Ubuntu 9.04 Jaunty Jackalope

sudo aptitude install linux-restricted-modules-`uname -r` linux-generic

After installing the modules, you will need to reboot. If the modules are already installed, proceed to the next step to check to see whether your hardware is recognizing the sound card as installed:

Is the sound card physically installed and recognized by your hardware?

Open a terminal window, and type

lspci -v | less

This will check your computer's motherboard, and attempt to list out all devices that it's recognized as installed. There is probably a lot of things listed, but the one you're looking for will be labeled "Audio device". Mine is listed below:

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)
	Subsystem: Toshiba America Info Systems Device ff01
	Flags: bus master, fast devsel, latency 0, IRQ 22
	Memory at dc440000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: <access denied>
	Kernel driver in use: HDA Intel
	Kernel modules: snd-hda-intel

Most users have a "built in" sound card for their computer on the motherboard. If yours is built in, and isn't showing up in this step, then you probably need to enable it in your BIOS. When you first boot, or reboot your computer, there's usually a key sequence telling you how to enter the BIOS Configuration Screen. You'll need to sort through your BIOS and enable the built in sound card. If you are not using a built in sound card, and this step does not show your audio card, the card may be seated incorrectly on your motherboard, or may be bad or otherwise incompatible with your motherboard. You will probably want to test the card in another computer to see if it works there.

Is my SoundCard supported?

The Advanced Linux Sound Architecture (ALSA) is the system that Ubuntu uses for managing Sound output. There is a listing of all of the sound cards supported by ALSA at http://www.alsa-project.org/main/index.php/Matrix:Main . You should look for the information that was listed by lspci in the previous step. If it turns out that your soundcard is not supported by ALSA, you have basically two different options: Get a new soundcard that is supported by ALSA, or contact the ALSA developers to request support for your soundcards. Important syntax note: ALSA modules are denoted by the prefix 'snd' followed by the dash ' - ', followed by the module name (i.e. 'via82xx'). So the full name might be something like snd-via82xx. However, in some cases you will see an underscore ' _ ' instead of the dash. This is OK, do not let it confuse you. When mentioning module names (to install them or communicate their names to others) only use the dash ' - '.

Is ALSA using the correct model?

If you are experiencing problems with your sound card after upgrading to Ubuntu 9.04, it might be because ALSA is using the wrong model for your chipset. To figure out your chipset you can run this command:

wget -O alsa-info.sh http://alsa-project.org/alsa-info.sh && bash ./alsa-info.sh

This will provide you with a URL to a webpage with lots of information about your sound setup. Open it up, and keep it open; you'll need it as a reference. You can take a look at this webpage as a reference. Now you need to figure out what models are supported by your soundcard. This part is a bit backwards, you have to browse the ALSA git repository. The repository is located at [1], so open up this URL. If you look at the webpage with information about your soundsetup, you'll notice it has a section like this:

!!ALSA Version
!!------------

Driver version:     1.0.18
Library version:    1.0.18
Utilities version:  1.0.18

Notice the driver version. This is the version you should be navigating to in the git repository. If you look at the 'tags' section there's a tag called v1.0.18, which is the one we want. When I navigated into this tag repository, I also had to click the tree link on the top of the page to get a directory listing. Click the Documentation directory, and then click ALSA-Configuration.txt. Remember these links are for the v1.0.18 driver version only, you need to find the appropriate ALSA-Configuration.txt for your driver version. Now you need to figure out what module is loaded by ALSA on your machine. The webpage with all the information about your system comes to the rescue again:

!!Loaded ALSA modules
!!-------------------

snd_hda_intel

You might have to do a bit of digging to find your module in the ALSA-Configuration.txt file. For my module, it is in the section called:

Module snd-hda-intel

Now I have to figured out what Codec my soundcard uses. This is also on the webpage with my sound configuration. It has a section that looks like this:

!!HDA-Intel Codec information
!!---------------------------
--startcollapse--

Codec: SigmaTel STAC9227

Now take a look at ALSA-Configuration.txt again, and you will find a section that looks like this, which matches up with my soundcards codec:

   STAC9227/9228/9229/927x
   ref           Reference board
   3stack        D965 3stack
   5stack        D965 5stack + SPDIF
   dell-3stack   Dell Dimension E520
   dell-bios     Fixes with Dell BIOS setup

A stack is the same as a jack plug in your soundcard. By inspecting your computer you have to figure out how many jacks you have on your soundcard. I have six jacks in the back and two in the front of my computer, so I chose the 5stack model configuration. So armed with this knowledge, it's about time to start configuring your system. This is the steps that were necessary to get a Dell Dimension E520 with Intel HDA and SigmaTel STAC9227 Codec to work after upgrading to Ubuntu 9.04:

sudo nano /etc/modprobe.d/alsa-base.conf

This part will depend on your soundcard, it consists of the module name (snd-hda-intel) and the model I found in ALSA-Configuration.txt, 5stack:

options snd-hda-intel model=5stack

And finally:

sudo alsa force-reload

Manual Installation

Once you've done the basic troubleshooting listed above, if things still aren't working, you may have found a bug in Ubuntu. It could be something as simple as not detecting your hardware the first time or evidence of a deeper problem. Ubuntu developers need your feedback to see what is not working for you. If you've reached this point, you should file a bug report on http://launchpad.net under the Ubuntu distribution. You should probably include the lspci and aplay output listed above in your bug report. Filing a bug report may seem like a worthless exercise, but it really helps in the development process.

Manually starting the Audio driver

Open a terminal and type sudo modprobe snd-[NAME OF YOUR SOUNDCARD'S DRIVER]. For example, my driver is a via82xx so I would type, sudo modprobe snd-via82xx. After this, try playing some sound. You may want to check the volume levels again, if you hear sound, it means that your installation isn't auto-detecting your sound card, but you have all of the right software. We've temporarily loaded the driver, but it will not be installed on the next reboot. You can override the auto-detection and force your computer to load the driver on every reboot by adding the driver (i.e. snd-via82xx) to the /etc/modules file. Type gksudo gedit /etc/modules at the command line, and add your sound driver as the last line of the file. Save the file, and reboot to verify that the sound is working after a reboot. Even if this step works, you should file a bug with the Ubuntu developers at http://launchpad.net so they can begin working on it to understand why your computer isn't auto-detecting the soundcard.

Refreshing/Reinstalling the drivers

Sometimes, sound might be configured correctly, but for some reason or another (tinkering) it stops working. If this is the case, you can purge your custom changes, and restore your system to a clean base. This may clear up your problem, and restore you to a working state. Open a terminal and type sudo aptitude --purge reinstall linux-sound-base alsa-base alsa-utils linux-image-`uname -r` linux-ubuntu-modules-`uname -r` libasound2. This will purge any custom configurations that you've made, and any hand-compiled modules that you've built, and restore your sound stack to the "Official" Ubuntu core. You can also do this as two separate steps: sudo apt-get --purge remove linux-sound-base alsa-base alsa-utils and then sudo apt-get install linux-sound-base alsa-base alsa-utils , but this may result in some other packages which depend on the sound-base and alsa-utils from being removed, such as gdm and ubuntu-desktop. If this happens, then do sudo apt-get install gdm ubuntu-desktop

Another way to restore ALSA to the Ubuntu default

I installed alsa from source, and wanted to revert so I wouldn't have to reinstall alsa everytime the kernel moved. The above did not work for me. Here's a safer way that did. That re-grabs all of the alsa binaries and modules. You may also need to ls -lt /lib/modules/`uname -r`/kernel/sound/ And delete anything from the day you manually installed alsa.

ALSA driver Compilation

  • If you are here, then either your soundcard driver could not be loaded with modprobe, or you want to compile the drivers yourself from scratch. Good luck to you!
  • There are two main ways the sources of alsa-drivers are made available to you. One is through the apt-get system. Using this system would be the recommended system since most of the heavy lifting is done for you.
  • The other way, is getting the latest drivers from alsa-project.org. This page has the latest drivers available, which you might want to fix problems with. However, these have not been tested with Ubuntu and therefore should be used with caution.

Using alsa-source

Open up a shell: (note: module-assistant is optional, it will compile the package for you)

  • Type sudo apt-get install build-essential linux-headers-$(uname -r) module-assistant alsa-source
  • Type sudo dpkg-reconfigure alsa-source
  • You now have a big blue dialog box (left and right keys to choose 'Yes' and 'No', Enter key proceed). Answer yes (for ISA-PNP - recommended by package maintainers), then yes again (for debugging - recommended by package maintainers).
  • Now you must pick which driver you want to install. Use space to select and deselect modules, and up and down to navigate.
  • From General Help step 3, you should know the name of your driver. Deselect 'all' (the * will go away), and select your driver. In my case, I deselected 'all' then selected 'via82xx'. Hit Enter. Almost home free!
  • If you chose module-assistant sudo module-assistant a-i alsa-source. If the progress bar reaches 100% with no errors, you will have installed the drivers successfully. Resume this guide from General Help step 4. You may need to run tail -F /var/cache/modass/alsa-source.buildlog.$(uname -r).* to see the progress.
  • If you did not choose module-assistant - Remember the name of your soundcard driver (eg. via82xx) and use it in place of <insert driver> below.
cd /usr/src
sudo tar xjvf alsa-driver.tar.bz2
cd alsa-driver<insert alsa version, if necessary>
sudo ./configure
sudo make
sudo make install
  • If you get no error messages, you will have installed the drivers successfully.
    • Success - Resume this guide from General Help step 4.
    • Failure - Start a new thread in this thread of the forum. Paste the error message that you get and state that you were following instructions on this page.

Using drivers from alsa-project

Update: The instructions below are outdated. Please see http://ubuntuforums.org/showthread.php?t=962695 for a convenient script that will build the latest ALSA release The alsa-project route is very similar to the alsa-source route without the module-assistant. First you would have to get the alsa-driver tar from alsa-project then pretty much do configure, make and make install again. However, I do recommend that you make a specific directory when you compile something from source. Remember the name of your soundcard driver and use it in place of the blue text below.

mkdir src
cd src
mkdir alsa
cd alsa
sudo apt-get install build-essential linux-headers-$(uname -r)
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.12.tar.bz2
tar -xvjf alsa-driver-1.0.12.tar.bz2
cd alsa-driver-1.0.12
sudo ./configure
sudo make
sudo make install

If you get no errors from doing the above then you have successfully compiled alsa-drivers from source. Resume this guide from General Help step 4.

Having sound issues with HP dvx laptop

If you have an HP dv4, dv5, and perhaps a dv7 model series laptop, you may have sound issues. ex: HP Pavilion dv4 1225, HP Pavilion dv5 1044ca, etc... - this fix work greet with Jaunty Jackalope (Ubuntu 9.04) 30 apr 2009 - the alsa developers have a solution for this issue: The cause, according to some alsa developers, is an incorrect 'pin' assignment (in the BIOS, perhaps) whereby sound output meant for the internal speakers gets routed to the wrong place. The latest alsa-driver snapshot provides a fix for this issue. You can get it here:

cd ~
mkdir src
cd src
mkdir alsa
cd alsa
wget ftp://ftp.kernel.org/pub/linux/kernel/people/tiwai/snapshot/alsa-driver-snapshot.tar.gz
tar -xvpf alsa-driver-snapshot.tar.gz
cd alsa-driver
sudo ./configure
sudo make
sudo make install-modules

Optional:

sudo vim /etc/modprobe.d/alsa-base.conf

[add 'options snd_hda_intel model=hp-dv5' sans quotes to the bottom of the file, even if you have a dv4, etc.]

sudo reboot

Another possibility for HP dv7 laptops

The above procedure did not work for my dv7, but the on-line fix at http://forum.notebookreview.com/showthread.php?t=331172 got things working. --PeterWhittaker

... which also worked for HP dv4

options snd-hda-intel enable_msi=1

Using alsamixer

  • Type this into a shell alsamixer

You will now see what appears to be a graphical equalizer. It is more like ten different volume controls in the sample place.

  • To navigate around:
    • Left and Right Arrow Keys - Move left and right (if you move long enough in one direction you will get back to where you started - you will not fall off the screen )
    • Up and Down Arrow Keys - Increase and decrease volume respectively.
    • Letter M Key - Mutes/unmutes. If a channel is unmuted, then there is a green box underneath the volume slider. If the channel is muted, the box is grey.

Saving Sound Settings

Do this step to ensure that your alsamixer settings are reloaded with each boot. First make sure you have your settings just the way you like them in alsamixer. Then do sudo alsactl store 0 or if this is your nth sound card (where n is the number of soundcards in your computer) replace 0 with n-1. Many thanks to xpix for trying this out.

Loading a working sound configuration

If you can find someone with similar HW as yours and has working sound, you could take their settings and try them on your HW.

  1. Get a working /var/lib/alsa/asound.state from someone who has similar hardware
  2. Save it as /tmp/asound.state
  3. alsactl -F -f /tmp/asound.state restore

Getting more than one application to use the soundcard at the same time

  • You might want to play a game and listen to music on your favorite music player at the same time. To do this successfully, you will have to use ALSA since it supports this feature the best. On all the music players I know of, you can configure the sound engine, to any module that is available.
  • The setting is usually found under something like Tools >>> Configure >>> Player Engines.
  • For games, it is a bit more tricky since there is not always a way to configure the player engine directly. Most games, however, do support the OSS. ALSA has an OSS module that allows OSS applications to use the ALSA driver.
  • To do this you will need the alsa-oss package sudo apt-get install alsa-oss
  • After doing this step, it is very easy to use alsa-oss. In the shell, you can type 'aoss' then the name of the program name you want to use with alsa-oss.

Configuring default soundcards / stopping soundcards from switching

Note: This section assumes that you have installed each soundcard properly.

  • In a shell, type cat /proc/asound/modules
  • This will give the the name and index of each soundcard you have currently. Make a note of the names, and decide which one you want to be the default card.
  • Now type sudo nano /etc/modprobe.d/alsa-base.conf
  • At the very end of the file, add the following (assuming you have 3 cards with module names A, B and C and you want to have them in the order CAB)
options snd-C index=0
options snd-A index=1
options snd-B index=2

Getting ALSA to work after suspend / hibernate

Some soundcards does not work after the computer has been suspended or hibernated. Files in /etc/pm/sleep.d/ are read when the system is entering or leaving suspend mode. Create a file telling the system to restart alsa when the computer is being brought up from suspended mode to make the audio work again. The command /sbin/alsa force-reload will kill all running programs using the sound driver so the driver itself is able to be restarted.

sudo nano /etc/pm/sleep.d/50alsa
#!/bin/sh
case "$1" in
        hibernate|suspend)
                # Stopping is not required
                ;;
        thaw|resume)
                /sbin/alsa force-reload
                ;;
        *) exit $NA
                ;;
esac

Make the newly created script to be executable with the following command:

sudo chmod +x /etc/pm/sleep.d/50alsa

Getting MIDI To Work - *EXPERIMENTAL*

This section assumes you can successfully hear sound from your soundcard. First of all, make sure that you actually have a MIDI port on your soundcard. Most onboard soundcards do not have a MIDI port. Next, open up this file: sudo nano /etc/modprobe.d/alsa-base Then add this options line options <snd module name here i.e. snd-via82xx> mpu_port=0x330 OR if you already have a options line for this soundcard add mpu_port=0x330 to the line. The default MIDI port is 330. You should verify this number in your BIOS if you are not sure. If the number is not listed, it is most likely that the number is 330 (add the 0x for the file). If you get no errors, you have successfully installed your MIDI port. At the moment, I do not know if any further configuration is necessary.

Getting Line Input to work (Microphone, etc)

Changing default subdevice configuration

  • Some sound devices have multiple capture subdevices (eg. hda-intel), but pulseaudio only seems to detect the parent device, and only listens to subdevice #0. ALSA may not be configured to use your preferred device as subdevice #0 by default.
  • Open the pulseaudio record meter (pavumeter --record)
  • Talk into your chosen device while you carry out the process and watch the meter.
  • Some channels are quite noisy even with no input (especially on integrated chipsets), so we are watching for movements that correspond to our voice.
  • Use alsamixer -c n (where n is your sound card number, probably 0)
  • Press F4 to get to the capture console
  • Make sure the first capture channel is enabled ("CAPTUR" in red, press space to toggle), and the volume turned up.
  • Check the first input source is switched to your chosen plug (Mic, in my case)
  • At this point, you should see the record meter bouncing in response to your voice.
  • I found that I had to repeat this procedure each time I wanted to use the Mic, even though the settings "stuck" in the mixer, something in the soundcard wasn't initialized until it was repeated.
  • This also works if you use the "Options" tab in the standard mixer app to do the same thing.

Miscellaneous Tips and Tricks

Here are a few things that other people have dug up over the course of this guide. Not all tips are meant to work for all hardware (believe me hda-intel will probably have like a mini guide of it's own one day).

I wasn't getting any sound out of my Sony Vaio PCG-4B1L ...The crucial thing is to enable everything in alsamixer EXCEPT "external amplifier." (I had to turn off microphone too, to stop feedback).

  • Useff had a very annoying problem where he could get sound through alsa from one user, but not through is main account. http://www.ubuntuforums.org/showthread.php?p=1221754. He and I managed to fix the problem by making sure the main account was in the audio group in /etc/group (which he was) and deleting the .asoundrc file in the main account's /home directory.
  • Bo Rosén solved his ISA problem the following way. Thanks to FarEast for his help in the matter.

Thanks to [[http://ubuntuforums.org/showthread.php?t=127402]] this post I got soundblaster 16 isa working. In short add{{{snd-sb16{{{ to /etc/modules then create a new file: {{{gedit /etc/modprobe.d/sound and enter this line:

options snd-sb16 isapnp=0 port=0x220 irq=5 dma8=1 dma16=5
sudo update-modules
reboot}}}
  • webbca01 figured out how to get AC'97 work with the help of the second last post here and this post. Basically, if you have an intel8x0 module, you can get AC'97 working by sudo nano /etc/modprobe.d/alsa-base and adding this as the last line: "options snd-intel8x0 ac97_quirk=3"
  • scragar noticed that sometimes even if ubuntu is set to use a particular sound card it still attempts to use a default sound card that may or may not be set, in which case
sudo apt-get install asoundconf-gtk && asoundconf-gtk will allow you to quickly change your default sound card(you may also uninstall asoundconf-gtk afterwards, provided you select remove and not "completely remove", from synaptic, or purge from the command line).
  • Sound did not work after resuming from suspend on my Acer Aspire 4720 running Kubuntu Hardy. /etc/init.d/alsa-utils restart (or reset) did not work, neither did any modprobing. Finally, sudo /sbin/alsa force-reload worked.
  • Make sure you are part of the audio group. This can be done by issuing the command groups. If you don't see audio here add youself to the audio group.

If All Else Fails...

By default, Ubuntu uses ALSA to communicate with sound hardware and uses PulseAudio as a sound server. If you've followed the troubleshooting guide(s), and still don't have your audio working properly consider replacing ALSA with the OpenSound System (OSS).

Advanced Guides by other Ubuntuers

To Do:

Important - no particular order

  • Getting MIDI to work
  • Getting line input to work if it does not already - for microphones, etc.
  • Getting SPDIF output to work if it does not already - for amplifiers, speakers with digital in.

On the backburner

  • Scripts for getting configuration that needs to be done in this post to be done automatically

Related

Getting keyboard multimedia keys to work - [MultimediaKeys] (I personally like the non-keytouch route - configuring xmodmap and then using gnome-keybindings or for KDE (System Settings >> Regional and Language Settings >> Keyboard Shortcuts). The xmodmap route also works for XFCE, but I do not how to configure XFCE application keybindings.

Posts / References /Credits

Hoary Sound Broke Problem with Azalia audio MultipleCards from alsa.opensrc.org Volume Control does not save my settings after reboot Every single sound problem error post I have read The Ubuntu community for being energetic, dynamic, and polite providers of help with Ubuntu Linux in all its flavours.

Getting support, Reporting Sound Bugs

Please do not report problems on this page; use the normal support channels instead. See http://www.ubuntu.com/support To find out how to collect relevant information for support or a bug report, see the BugSquad team sound page at https://wiki.ubuntu.com/DebuggingSoundProblems