Linux声卡问题通用解决方法
Contents
如果你的声卡不出声而找不到原因,请按着本文的顺序走一遍也许就能解决了 。(以ubuntu为例,原文在 http://ubuntuforums.org/showthread.php?t=205449)
(1)在shell下输入命令:
aplay -l
成功 - 你将能看到你的系统上已安装的声卡的列表。如果你的声卡已经列出了,那么很可能只是因为你的系统被设置禁音了。请参考 alsamixer 章节。
失败 - 你看到类似于这样的信息:aplay: device_list:221: no soundcard found... 请继续请下看。
(2) 在shell下输入命令:
lspci -v
成功 - 你应该看到你的声卡被列出来。这意味着 ubuntu 检测到了你的声卡,但是驱动没有安装或者驱动没有运行。
失败 - 如果没有被列出来,那么你可以尝试下面的步骤:
- 如果你的声卡是主板集成的声卡,那么有可能是在系统的BIOS中被禁用了。你需要重启进入BIOS检查相关设置。
- 如果你的声卡不是集成声卡,那么请确保你的声卡正确插好。如果你的声卡在Windows下工作正常,那么说明声卡的接触是正常的。
(3) 检查你的声卡相对应的ALSA驱动是否存在。请访问 http://www.alsa-project.org/alsa-doc/ 在下拉菜单中搜索你的声卡(芯片)或者厂商名。 你能会看到一个声卡厂商列表。看看是不是能找到第二步列出信息对应的芯片。
- 成功 - 你将发现你的声卡芯片对应的驱动
- 失败 - 你没有发现你的声卡芯片的驱动。(此刻我也不能帮你了!)
(4) 现在回到shell1,输入命令:
sudo modprobe snd-
现在,在敲回车键前按下TAB键,系统将列出一堆模块。试着找到匹配你在第三步找到的设备的驱动的模块。
例如,我的驱动是 via82xx ,因此我将输入 sudo modprobe snd-via82xx.
- 成功
- 意味着你的声卡安装成功了,只是没有被正确加载而已。刚才手动加载成功了。
- 想要所有的时候都正确加载,你需要编辑 /etc/modules
在 shell下输入命令:(当然也可以用vim/emacs/gedit...)
sudo nano /etc/modules
- 添加模块的名字到这个文件的末尾。在我的例子里, 加载 via82xx 模块能使我的声卡发声,那么我添加"snd-via82xx" 到文件的末尾。确认你的 alsamixer 中所有通道都在非静音状态。
- 参考 alsamixer 部分
- 使用你喜欢的媒体播放器播放。设置你的音频引擎为alsa。你可能已经设置了其它音频引擎,比如在 kubuntu 里设置为 kaffiene,如果你能听到声音,恭喜。
- 最后一步,保存声音设置。
- 失败 - 你有两种选择
- 跳到下一节“通过更新内核得到 ALSA 驱动支持”。这个方法比较简单并且适合那些希望在安装了 Ubuntu 之后仍能保持他们的声音设置的用户(当然,也就是不需要重新安装 Ubuntu)。
- 跳至“编译 ALSA 驱动”节,如果你还没有那么做。如果你已经自己编译了 ALSA 驱动,请张发布一张新帖子并描述你碰到的问题。
通过更新内核得到 ALSA 驱动支持
有时,声音设置可能在最开始得到正确的配置,但由于这样或那样的原因不工作了。一种恢复旧的可用配置的方式就是重新安装 Ubuntu。 但这样因为某个软件的缺陷重做全部的系统一点儿必要也没有。
另一个更快的解决方案就是,删除问题软件并重新安装正确的版本。
(1) 删除旧软件包
sudo apt-get --purge remove linux-sound-base alsa-base alsa-utils
(2) 重新安装被卸载的包
sudo apt-get install linux-sound-base alsa-base alsa-utils
重要提示: Ubuntu (GNOME) 用户曾经报告他们的 'gdm' 和 'ubuntu-desktop' 因为依赖性关系在卸载 linux-sound-base 的同时也被卸载了。如果您也碰到这样的问题,可以执行下面的命令来重新安装
sudo apt-get install gdm ubuntu-desktop
重要提示: Xubuntu (XFCE)用户曾经报告他们的 'gdm' 和 'xubuntu-desktop' 因为依赖性关系在卸载 linux-sound-base 的同时也被卸载了。如果您也碰到这样的问题,可以执行下面的命令来重新安装
sudo apt-get install gdm xubuntu-desktop
(3) 重新启动。现在你可能会问“我已经有了这些包,为什么我能通过删除它们然后再重新安装来解决问题呢?”答案就在这个特殊的 --purge 参数,它会删除任何在更新或者升级过程中产生的配置信息。当软件被重新安装以后他们就会像被第一次安装进系统一样。
(4) 这时你应该可以通过执行下面的命令列出你的声卡了
aplay -l
- 成功 - Your soundcard is detected. Go onto the Using alsamixer section, then try playing something on your music or media player.
- Failure - Your card was not detected. You should try compiling your driver, so go onto ALSA driver Compilation.
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 though 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
Type the following to shell: (note: module-assistant is optional, it will compile the package for you)
sudo apt-get install build-essential linux-headers-$(uname -r) module-assistant alsa-source 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.If you did not choose module-assistant - Remember the name of your soundcard driver and use it place of the blue text below.
cd /usr/src sudo tar xjvf alsa-driver.tar.bz2 cd modules/alsa-driver sudo ./configure --with-kernel=/usr/src/linux-headers-$(uname -r) --with-cards=<enter driver name here e.g. via82xx> --with-oss=yes 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 I now recommend using the stable version 1.0.12
- 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 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/drive....12rc2.tar.bz2 tar xvjf alsa-driver-1.0.12rc2.tar.bz2 cd alsa-driver-1.0.12rc1 sudo ./configure --with-kernel=/usr/src/linux-headers-$(uname -r) --with-cards=<enter driver name here e.g. via82xx> --with-oss=yes 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.
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 ) o
- 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.-
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 Code: 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 multiple soundcards from switching
Note: This section assumes that you have installed each soundcard properly.
- In a shell, type Code: 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 Code: sudo nano /etc/modprobe.d/alsa-base
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
Adding the current user to the audio group
A very common cause for a user to not have sound is not having his/her username in the /etc/group. 2
grep 'audio' /etc/group
You should see a line similar to
audio:x:29:
followed by a username i.e. if the username is "ubuntu" then you should see
audio:x:29:ubuntu
If you see something else i.e.
audio:x:29:root
you should add your username to the file by doing
sudo nano /etc/group
Now find the line that looks like
audio:x:29:root
and change it to
audio:x:29:root:moocow
only replacing moocow with your real username.
Hit CTRL + 0 to save, then CTRL + X to exit. That's the end of that
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.
小帖士
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).
shaviro found the following from this post http://www.ubuntuforums.org/showthread.php?t=153752
> 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. Him and I managed to fix the problem by making sure the main account was in the audio group in /etc/groups (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. Quote: 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
and then
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
对于 Ubuntu 用户的一些高级指南
- Soundblaster Audigy 2 AC3 Passthrough - Howto by dave_euser
更多资料
http://www.sabi.co.uk/Notes/linuxSoundALSA.html - Some advanced reading on ALSA - thanks segalion