arecord命令怎么没出现保存文件,我在虚拟机上测试都可以,在arm开发板板上执行录音命令,生成不了保

From ArchWiki
ALSA 的使用、配置及疑难解答。
翻译状态: 本文是英文页面
的,最后翻译时间:,点击可以查看翻译后英文页面的改动。
(Advanced Linux Sound Architecture,ALSA)是Linux中提供声音设备驱动的内核组件,用来代替原来的开放声音系统(Open Sound System,OSSv3)。除了声音设备驱动,ALSA还包含一个用户空间的函数库,以方便开发者通过高级API使用驱动功能,而不必直接与内核驱动交互。
注意: 关于另一种声音体系,请阅读的页面。
Arch 默认的内核已经通过一套模块提供了 ALSA,不必特别安装。
会在系统启动时自动检测硬件,并加载相应的声音设备驱动模块。这时,你的声卡已经可以工作了,只是所有声道默认都被设置成静音了。
在本地登录(通过虚拟终端或登录管理器)的用户,都有权限播放音频并调整音量。要让远程登录的用户拥有这些权限,必须把用户 audio 用户组。该组的成员可以直接访问声音设备,会导致某些程序独占音频输出(破坏软件混音),还可能影响用户快速切换和拖机(multiseat)。因此,除非真的有某些,不建议把用户加入 audio 用户组。
软件包,其中的 alsamixer 工具允许用户在控制台或终端中配置声音设备。
软件包,如果想让 OSS 应用程序与dmix(软件混音)协同工作。
注意: 从的171版本开始,默认情况下 OSS 仿真模块(snd_seq_oss、snd_pcm_oss、snd_mixer_oss)不再自动加载。
软件包,如果需要 、和其他高级特性。
目前版本的 ALSA 安装后,所有声道默认是静音的,必须手动解除。
使用 alsamixer 的 ncurses 界面,配置十分简单:
$ alsamixer
此外,还可以在命令行下使用 amixer:
$ amixer sset Master unmute
在 alsamixer 中,下方标有 MM 的声道是静音的,而标有 00 的通道已经启用。
使用左右方向键,选中 Master 和 PCM 声道。按下
键解除静音。使用上方向键增加音量,直到增益值为0。该值显示在左上方 Item: 字段后。过高的增益值会导致声音失真。
要想得到完整的 5.1 或 7.1 环绕立体声,还得解除 Front、Surround、Center、LFE (subwoofer) 和 Side 这些声道的静音(上述名称是 Intel HD Audio 声卡使用的声道名,可能因设备不同而有所差异)。注意,仅有这些设置,系统不会自动将立体声源(多数音乐)提升(upmix)成环绕立体声。如果需要这些功能,请阅读。
要启用麦克风,切换至 Capture 选项卡,按下 ,按下
启用其中一个声道即可。
键退出 alsamixer。
有一些声卡,需要关闭数字输出或将其调成静音,才能输出模拟音频信号。对于
Soundblaster Audigy LS 声卡,需要把 IEC958 通道设成静音。
有些机器(如 Thinkpad T61),有一个 Speaker 通道,必须按照上述方法打开调整。
有些机器(如 Dell E6400),可能还需要把 Front 和 Headphone 声道打开调整。
接下来,测试声卡是否工作:
$ speaker-test -c 2
根据扬声器的实际情况,调整 -c 后的数值。对于 7.1 声道,这个数字是 8:
$ speaker-test -c 8
如果没有正常工作,请继续阅读
软件包提供了两个配置 alsa 的服务:alsa-restore.service 和 alsa-store.service。它们分别在开机和关机时自动运行。
如果使用 VirtualBox 时碰上了麻烦,请尝试以下命令:
$ alsactl init
Found hardware: &ICH& &SigmaTel STAC& &AC97a:& &0x8086& &0x0000&
Hardware is initialized using a generic method
如果还是不行,请检查所使用的音频软件是否激活了 ALSA 输出。
如果发现开机时声卡次序会发生变化,可以在通过 /etc/modprobe.d 中的 .conf 文件(比如 /etc/modprobe.d/alsa-base.conf)手动设置次序。
比如,要让 mia 声卡成为 #0、Intel HDA 声卡成为 #1:
/etc/modprobe.d/alsa-base.conf
options snd slots=snd_mia,snd_hda_intel
options snd_mia index=0
options snd_hda_intel index=1
使用 lsmod | grep snd 获取设备列表。
snd_mia 和 snd_hda_intel 分别是两个声卡的内核驱动模块。该配置仅适用于同时装有 mia 声卡和使用 snd_hda_intel 驱动的声卡(通常是板载声卡)的情况。
如果使用 -2 的 index 值,ALSA 就不会将对应的设备作为主声卡使用。Linux Mint 和 Ubuntu 等发行版使用了以下配置,避免 USB 声卡和其他“非主流”设备变成 index 为 0 的主声卡:
/etc/modprobe.d/alsa-base.conf
options bt87x index=-2
options cx88_alsa index=-2
options saa7134-alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
options snd-usb-audio index=-2
options snd-usb-caiaq index=-2
options snd-usb-ua101 index=-2
options snd-usb-us122l index=-2
options snd-usb-usx2y index=-2
# Keep snd-pcsp from being loaded as first soundcard
options snd-pcsp index=-2
# Keep snd-usb-audio from beeing loaded as first soundcard
options snd-usb-audio index=-2
以上配置会在系统重启后生效。
This article or section is out of date.
Reason: 据英文 Wiki 用户反应,/etc/asound.conf 这个配置文件默认是不存在的,下列操作可能有误。 ()
首先,运行 aplay -l,获取声卡的声卡ID和设备ID:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
拿输出中的最后一项来说,这个声卡的声卡ID为2,设备ID为0。若要把这块声卡作为默认声卡,可以把下列配置添加到系统级别的 /etc/asound.conf 或用户级别的 ~/.asoundrc 文件。如果文件不存在,可以手动创建。其中的各个ID,请根据实际情况调整:
defaults.pcm.card 2
defaults.pcm.device 0
defaults.ctl.card 2
“pcm”选项决定用来播放音频的设备,而“ctl”选项决定那个声卡能够由控制工具(如 alsamixer)使用。
上述配置在重启音频程序(如 mplayer)后立即生效。
一般 udev 都会自动识别出声卡。使用以下命令确认:
$ lsmod | grep '^snd' | column -t
snd_hda_codec_hdmi
snd_hda_codec_realtek
snd_hda_intel
snd_hda_codec
snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel
snd_hda_codec
snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
snd_page_alloc
snd_hda_intel,snd_pcm
如果你的输出和上面类似,那就说明声卡已经被正确识别。
注意: 从的171版本开始,默认情况下 OSS 仿真模块(snd_seq_oss、snd_pcm_oss、snd_mixer_oss)不再自动加载。如有需要,请。
还可以检查一下 /dev/snd/ 目录,看看是否有这些设备文件:
$ ls -l /dev/snd
crw-rw----
1 root audio 116,
8 14:17 controlC0
crw-rw----
1 root audio 116, 32 Apr
8 14:17 controlC1
crw-rw----
1 root audio 116, 24 Apr
8 14:17 pcmC0D0c
crw-rw----
1 root audio 116, 16 Apr
8 14:17 pcmC0D0p
crw-rw----
1 root audio 116, 25 Apr
8 14:17 pcmC0D1c
crw-rw----
1 root audio 116, 56 Apr
8 14:17 pcmC1D0c
crw-rw----
1 root audio 116, 48 Apr
8 14:17 pcmC1D0p
crw-rw----
1 root audio 116,
8 14:17 seq
crw-rw----
1 root audio 116, 33 Apr
8 14:17 timer
注意: 在 IRC 或论坛寻求这方面帮助时,别忘了贴出上面几个命令的输出。
如果你的输出跟上面类似,或至少有 controlC0 和 pcmC0D0p,那么声卡就已经正常加载了。
如果出现问题,声卡模块没有正确加载,那么请尝试手动加载模块:
确定声卡对应的驱动模块:。这些模块都会有一个”snd-“前缀(例如:snd-via82xx)。
检查 /dev/snd 目录中的设备文件(参见上文);或者,检查 alsamixer 或 amixer 的输出是否正确。
修改配置,使 snd-&模块名& 和 snd-pcm-oss 模块。
(由 Gentoo 论坛的 gralves 提供)
在 GNOME 音量控制的选项(Options)标签中,把 IEC958 改成 PCM。该选项可以在首选项中启用。
不使用 GNOME 音量控制工具的话:
编辑 /var/lib/alsa/asound.state。该文件是 alsasound 保存混音器设置的地方。
找到这一行:“IEC958 Playback Switch”。该行上下应该有一行内容为 value:false,将其改为 value:true。
再找到这一行:”IEC958 Playback AC97-SPSA“。把对应的值改为 0。
重启 ALSA。
This article or section is out of date.
Reason: rc.local 在 systemd 中已经弃用,以下方法可能不再适用。 ()
还有另外一个开机自动启用 SPDIF 输出的方法(在 SoundBlaster Audigy 声卡上测试过):
在 /etc/rc.local 中添加如下内容:
# Use COAX-digital output
amixer set 'IEC958 Optical' 100 unmute
amixer set 'Audigy Analog/Digital Output Jack' on
使用以下命令,获取你的声卡的数字输出的名称:
$ amixer scontrols
注意: 如果使用的是64位系统,而又安装了32位的 Flash 插件,这里的设置会导致 Flash 无声。如果发生了这种情况,请禁用 alsaequal 或编译32位版本的 alsaequal。
安装后,把下列内容添加到 ALSA 配置文件(~/.asoundrc 或 /etc/asound.conf):
ctl.equal {
pcm.plugequal {
# Modify the line below if you do not
#slave.pcm "plughw:0,0";
#by default we want to play from more sources at time:
slave.pcm "plug:dmix";
#pcm.equal {
# If you do not want the equalizer to be your
# default soundcard comment the following
# line and uncomment the above line. (You can
# choose it as the output device by addressing
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)
pcm.!default {
设置好后,切换均衡器:
$ alsamixer -D equal
需要注意,每个用户的 alsaequal 配置文件都是独立的,位于 ~/.alsaequal.bin。因此,如果想在
之类的以独立用户身份运行的程序中使用 AlsaEqual,就得像下面这样:
# su mpd -c 'alsamixer -D equal'
或者,在其他用户的主目录下创建符号链接,指向你的 .alsaequal.bin……
同上,配置均衡器:
$alsamixer -D equal
如果对效果感到满意,将其命名(如“foo”)并保存该配置:
$alsaequal-mgr save foo
重新加载“foo”中的配置:
$alsaequal-mgr load foo
这样,就可以为游戏、电影、不同音乐流派、网络电话等等创建不同的均衡器配置,以便随时切换。
参见和程序的帮助信息,了解更多设置。
注意: 该软件用到了一个 ladspa 插件,可能导致播放音频时 CPU 占用率偏高。In addition, this was made with stereophonic sound (e.g. headphones) in mind.
安装 、 和
在 ~/.asoundrc 或 /etc/asound.conf 中添加如下内容:
/etc/asound.conf
type ladspa
# The output from the EQ can either go direct to a hardware device
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go
# to the software mixer shown here.
#slave.pcm &plughw:0,0&
slave.pcm &plug:dmix&
# Sometimes you may need to specify the path to the plugins,
# especially if you have just installed them.
Once you have logged
# out/restarted this should not be necessary, but if you get errors
# about being unable to find plugins, try uncommenting this.
#path &/usr/lib/ladspa&
label mbeq
#this setting is here by example, edit to your own taste
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,
#50000hz, 10000hz, 20000hz
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]
# Redirect the default device to go via the EQ - you may want to do
# this last, once you are sure everything is working.
Otherwise all
# your audio programs will break/crash if something has gone wrong.
pcm.!default {
slave.pcm &eq&
# Redirect the OSS emulation through the EQ too (when programs are running through &aoss&)
pcm.dsp0 {
slave.pcm &eq&
完成。若有问题,欢迎前往论坛咨询。
启用软件混音时,ALSA 会强制把所有音频重采样到相同的频率(如果系统支持,默认是 48000)。dmix 的重采样算法很糟糕,会导致显著的质量损失。
将默认的采样率转换器更改为 libsamplerate:
/etc/asound.conf
defaults.pcm.rate_converter "samplerate_best"
~/.asoundrc
defaults.pcm.rate_converter "samplerate_best"
samplerate_best 输出的声音质量最佳,但需要耗费大量CPU资源进行实时重采样。还有其他的算法可供选择(如 samplerate 等),但比起默认的算法,这些算法的改进并不明显。
警告: 某些系统中,启用 samplerate_best 可能导致 Flash 播放器无声音。
注意: 由于未找到 upmix 和 downmix 的常用翻译,译者暂时采用字面翻译(上混、下混)。所谓“上混”,即将声道较少的立体声(如常见的双声道立体声)信号,通过软件或硬件处理,模拟为声道较多的立体声(如5.1环绕立体声)信号。反之即为“下混”。
播放双声道立体声音源(如音乐)时,利用上混,即可充分利用 5.1 或 7.1 环绕立体声的所有声道。以前,上混很麻烦,还经常出错。但如今就方便多了,只需要安装一些插件即可。这些插件由
软件包提供。
安装后,在配置文件(/etc/asound.conf 或 ~/.asoundrc)中添加如下内容:
pcm.upmix71 {
type upmix
slave.pcm "surround71"
channels 8
该范例适用于7.1声道上混。类比该范例,同样能设置5.1或4.0声道上混。
该设置添加了一个新的用于上混的 pcm。如果希望所有音频源都通过该 pcm 输出,在上述设置后添加如下配置即可:
pcm.!default "plug:upmix71"
插件默认配置就允许多个音频源同时通过它输出,一般无需额外配置。如果不行,就得向下面这样为上混配置 dmixer:
pcm.dmix6 {
playback.pcm {
ipc_key 567829
pcm "hw:0,0"
channels 6
注意要用 dmix6 而非 surround71。
如果遇到声音卡顿或混乱,可能需要增加 buffer_size(比如增加到 32768),或使用。
有时也会用到下混,比如在只支持双声道立体声的电脑上观看5.1声道的电影时。这一功能由 ALSA 插件 vdownmix 实现(同样在
软件包里)。
在配置文件中添加如下内容:
pcm.!surround51 {
type vdownmix
slave.pcm "default"
pcm.!surround40 {
type vdownmix
slave.pcm "default"
注意: 在 ALSA 1.0.9rc2 及以上版本中,如果声卡不支持硬件混音,模拟输出将默认使用 dmix 混音,无需额外设置。
如果软件混音未正常启用,那么可以手动创建 ~/.asoundrc,加入以下内容:
slave.pcm "dmix"
这样就启用了软件混音,多个程序能够同时使用声卡。
至于 S/PDIF 之类的数字音频输出,目前的 ALSA 还不会默认启用 dmix。因此,必须像上面这样手动启用。
常见问题的解答,参见部分。
如果声卡支持,一般无需任何配置即可启用硬件混音。绝大多数板载声卡都不支持硬件混音,必须得使用软件混音(见上文)。很多独立声卡都支持硬件混音,Linux 下支持较好的有:
Creative SoundBlaster Live! (5.1 型号)
Creative SoundBlaster Audigy (部分型号)
Creative SoundBlaster Audidy 2 (ZS 系列型号)
Creative SoundBlaster Audigy 4 (Pro 系列型号)
注意: 上述声卡的低端版本(Audigy SE、Audigy 2 NX、SoundBlaster Live! 24bit 以及 SoundBlaster Live! 7.1)使用了不同的芯片,不支持硬件混音。
注意: 板载 VIA8237 芯片支持4路硬件混音,但在某些主板上只能使用3路(第4路无声),甚至根本无法使用。即使能正常工作,质量也比不上其他混音方法。
如果你的声卡是 Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02),且使用了64位系统,需要执行以下命令才能在 Enemy Territory 中听到声音:
echo "et.x86 0 0 direct" & /proc/asound/card0/pcm0p/oss
echo "et.x86 0 0 disable" & /proc/asound/card0/pcm0c/oss
使用 ondemand 或 conservative 频率策略、启用CPU频率动态调整时,某些声卡和某些 ALSA 驱动会出现声音跳跃的情况。目前,唯一的解决方案是使用固定的频率,如 performance 性能策略。
详情参见 。
有时会出现一个用户独占软件混音器的情况。多数情况下这没什么影响,但在使用
这样以独立用户身份运行的程序时,就会出现问题。当 mpd 运行时,用户自己就无法播放其他音频了。一种解决方法是,以正在使用的用户身份运行 mpd。另一种方法是,在 ALSA 配置文件的 pcm.dmixer 部分添加 ipc_key_add_uid 0 禁止独占。以下是 asound.conf 示例的片段,省略的部分无需修改:
pcm.dmixer {
ipc_key 1024
ipc_key_add_uid 0
ipc_perm 0660
如果安装了 (可能作为
的依赖被安装),可能出现无法同步播放的问题,因为 PulseAudio 的默认配置是“独占”声卡。ALSA 的用户可能对自己的配置已经很满意、不希望使用 。解决方案是编辑 /etc/asound.conf 并注释掉以下内容:
# Use PulseAudio by default
#pcm.!default {
type pulse
fallback "sysdefault"
description "Default ALSA Output (currently PulseAudio Sound Server)"
可能还需要注释掉下面的内容:
#ctl.!default {
type pulse
fallback "sysdefault"
比起完全卸载 ,这大概是个更简单的方法。
以下是 /etc/asound.conf 配置文件的一个示例:
pcm.dmixer {
ipc_key 1024
ipc_key_add_uid 0
ipc_perm 0660
slave.pcm &dmix&
注意: 本 /etc/asound.conf 本来是配合
全局配置使用的。参见关于多用户的内容。
如果会随机地出现开机无声的问题,原因可能是多声卡的顺序发生了变化。如果是这种情况,请参照进行设置。
对于 mpd 用户,上述配置无效,请参考设置。
对于不使用系统声音配置的程序,如 XMMS 和 Mplayer,必须特别设置以应用 ALSA 配置。
对于 mplayer,将以下内容添加到 ~/.mplayer/config (或系统全局配置文件 /etc/mplayer/mplayer.conf):
对于 XMMS 和 Beep Media Player,打开选项窗口,要把声音驱动设置为 ALSA 而不是 OSS。
XMMS 的设置方法:
选项 -& 首选项
选择 Alsa 输出插件
对于未提供 ALSA 输出的程序,可以使用 alsa-oss 软件包中的 aoss 工具启动。使用方法是:在要运行的程序的命令行前加上 aoss。例如:
aoss realplay
pcm.!default{ ... } 貌似已经不管用了。但下面的设置有效:
pcm.default pcm.dmixer
ALSA 会通过 BIOS 检测,少数情况下也可能无法正确识别。声卡芯片类型可以在 alsamixer 界面上找到(如 ALC662),而型号则要设置在 /etc/modprobe.d/modprobe.conf 或 /etc/modprobe.d/sound.conf 文件中:
options snd-hda-intel model=&型号&
具体设置因声卡型号而异。多数情况下不需要特地这样做。如果想知道具体声卡型号的设置,请查阅 ,找到你的声卡型号,点击“Details”,然后查看“Setting up modprobe...”小节,将其中的内容插入 /etc/modprobe.d/modprobe.conf 文件即可。例如,Intel AC97 的配置如下:
# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-intel8x0
# module options should go here
# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
如果你确认所有声道都已解除静音,声卡驱动配置正确,且音量大小也合适,但还是听不到声音,那么请试试将下面的内容添加到 /etc/modprobe.d/modprobe.conf:
(如果是 via82xx 驱动)
options snd-&模块名请自行补充& ac97_quirk=0
(如果是 snd_intel8x0 驱动)
options snd-NAME-OF-MODULE ac97_quirk=1
In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and D this make make static or distortion, but then you can adjust them back down once you are hearing something when you record
As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.
To test the microphone, run these commands (see arecord's man page for further information):
arecord -d 5 test-mic.wav
aplay test-mic.wav
If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.
For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.
Many Dell laptops need "-dmic" to be appended to the model name in /etc/modprobe.d/modprobe.conf:
options snd-hda-intel model=dell-m6-dmic
Some programs use try to use OSS as the main input software. Add the following lines to /etc/modprobe.d/modprobe.conf to prevent OSS modules from being loaded:
Note: The OSS modules are no longer autoloaded anyway.
blacklist snd_pcm_oss
blacklist snd_mixer_oss
blacklist snd_seq_oss
某些程序(Pidgin、Adobe Flash)提供了设置录音设备的选项。如果录音设备不是内置的声卡,而是外接的(如USB摄像头、麦克风),就会有些问题。如果只想更改默认的录音设备、不更改回放设备,需要像下面这样设置 ~/.asoundrc:
card U0x46d0x81d
pcm.!default
playback.pcm
slave.pcm "dmix"
capture.pcm
slave.pcm "usb"
把“U0x46d0x81d”替换为你的录音设备的名称。可以通过 arecord -L 查看所有 ALSA 识别到的录音设备。
首先,请检查 alsamixer,确保所有的录音声道的音量都达到可以录制的程度。如果还是不行,试试修改 /etc/sound.conf 并重载 snd-* 模块。这样就会多出来一个名叫 Capture 的音频控制,可以用它调节内置麦克风的音量。例如,对于 snd-hda-intel 模块,配置如下:
options snd-hda-intel enable_msi=1
然后,输入下面的命令重载模块,调整音量并测试。
# rmmod snd-hda-intel && modprobe snd-hda-intel
可能由两个相互冲突的驱动模块引起,分别是 snd_intel8x0 和 snd_intel8x0m。如果是的话,屏蔽 snd_intel8x0m 即可:
/etc/modprobe.d/modprobe.conf
blacklist snd_intel8x0m
以下方法可能也有效:在 alsamixer 或 amixer 把 “External Amplifier” 设置为静音。参见:。
也可以试试解除“Mix”的静音。
对于笔记本电脑上的 Intel Corporation 82801 I (ICH9 Family) HD Audio Controller 声卡,可能需要添加如下内容到 modprobe 配置文件或 sound.conf,以解决耳机无声的问题:
options snd-hda-intel model=$model
$model 在下列型号中选择:
dell-vostro
olpc-xo-1_5
laptop-hpsense
注意: 可能需要在配置文件的 "alias" 语句之后添加上述内容。
可以在内核文档中找到所有支持的型号,如。这是 2.6.35 版本内核的文档,你需要自己查找适用于自己内核版本的文档。
也可以从获取型号列表。要查看你的声卡芯片名称,输入下列命令(其中的“*”请根据实际情况替换)。注意,有些芯片名称被更改过,因此实际名称与文件中的可能不匹配。
cat /proc/asound/card*/codec* | grep Codec
注意,这么做很可能导致所有输入设备(内置和外置麦克风)无法工作,即要么让麦克风正常、要么让耳机正常。如果遇到这一问题,请向 ALSA 开发者报告。
另外,如果蜂鸣器(pcspkr)出现问题,可以试试使用以下配置修复:
options snd-hda-intel model=$model enable=1 index=0
检测已加载的相关模块,并记录顺序:
$ cat /proc/asound/modules
0 snd_hda_intel
1 snd_ca0106
在 /etc/modprobe.d/modprobe.conf 中禁用不希望使用的显卡的音频解码模块:
# /etc/modprobe.d/modprobe.conf
install snd_hda_intel /bin/false
如果不同设备使用同一模块,那么只能在 BIOS 中禁用其中之一。
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.
If snd-usb-audio driver has been loaded, you could try to enable softvol in /etc/asound.conf file. Example configuration for the first audio device:
pcm.!default {
slave.pcm "softvol"
pcm.dmixer {
ipc_key 1024
pcm "hw:0"
period_time 0
period_size 4096
buffer_size 131072
rate 50000
bindings {
pcm.dsnooper {
type dsnoop
ipc_key 1024
pcm "hw:0"
channels 2
period_time 0
period_size 4096
buffer_size 131072
rate 50000
bindings {
pcm.softvol {
type softvol
slave { pcm "dmixer" }
name "Master"
ctl.!default {
ctl.softvol {
ctl.dmixer {
Some modules (e.g. snd_ac97_codec and snd_hda_intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try modinfo snd_MY_MODULE, and look for a module option that adjusts or disables this feature.
Example: to disable the power saving mode and solve cracking sound trough speakers issue, using snd_hda_intel add in /etc/modprobe.d/modprobe.conf
options snd_hda_intel power_save=0
options snd_hda_intel power_save=0 power_save_controller=N
You can also try it with modprobe snd_hda_intel power_save=0 before.
You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).
Example: on an onboard VIA VT1708S (using the snd_hda_intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the issue.
If you use a laptop, pm-utils will change power_save back to 1 when you go onto battery power even if you disable power saving in /etc/modprobe.d. Disable this for pm-utils by disabling the script that makes the change (see
for more information):
# touch /etc/pm/power.d/intel-audio-powersave
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running
# iecset audio on
You can also put this command in rc.local as it sometimes it may stop working after a reboot.
If the HDMI output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try the following.
Query for Playback Devices:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 1: ALC1200 Digital [ALC1200 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 0/1
Subdevice #0: subdevice #0
Now that we have the info for the HDMI device, try a test,
In the example below, 0 is the card number and 3 is the device number.
$ aplay -D plughw:0,3 /usr/share/sounds/alsa/Front_Center.wav
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. In particular, if you are using a standalone window manager (don’t know about Gnome or KDE), you may need to have some sound playing while plugging in the HDMI cable.
Note: If you are using an ATI card and linux 3.0, check your kernel/grub settings, you most likely need to use the 'radeon.audio=1' boot parameter, or alternatively set up the option in your modprobe configuration files. It's important to note that before trying, is to check the
to see if it's actually supported. At the moment this is written (march 29th, 2013), some chipsets of the
(namely HD7750 through HD7970) doesn't (still) support HDMI Audio.
If the test is successful, create or edit your ~/.asoundrc file to set HDMI as the default audio device.
~/.asoundrc
pcm.!default {
Or you above config does not work try:
~/.asoundrc
defaults.pcm.card 0
defaults.pcm.device 3
defaults.ctl.card 0
As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:
Add these 2 lines into /etc/modprobe.d/modprobe.conf:
options snd-cmipci mpu_port=0x330 fm_port=0x388
options snd-hda-intel index=0 model=toshiba position_fix=1
options snd-hda-intel model=hp (works for tx2000cto)
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. & 2 speaker system), run alsamixer and disable the channels for the speakers that you DO NOT have (i.e. do not enable the sound for the center speaker if you do not have a center speaker.
If you are using a USB headset with ALSA you can try using
(currently only available from the ) to set the headset as the primary sound output. Before running make sure you have usb audio module enabled (modprobe snd-usb-audio).
# asoundconf is-active
# asoundconf list
# asoundconf set-default-card &chosen soundcard&
If you experience crackling sound on USB devices, you can try tuning the snd-usb-audio for minimal latency.
Add this to your /etc/modprobe.d/modprobe.conf:
options snd-usb-audio nrpacks=1
In order to automatically make a USB Sound Card the primary output device, when the card is plugged in, you can use the following udev rules (e.g. add the following two lines to /etc/udev/rules.d/00-local.rules and reboot).
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K & /etc/asound. echo defaults.pcm.card $$K &&/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 & /etc/asound. echo defaults.pcm.card 0 &&/etc/asound.conf'"
The following messages may be displayed during the start-up ALSA after the kernel update:
Unknown hardware "foo" "bar" ...
Hardware is initialized using a guess method
/usr/sbin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)
Found hardware: "HDA-Intel" "VIA VT1705" "HDA:00" "0x1849" "0x0397"
Hardware is initialized using a generic method
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)
Simply store ALSA mixer settings again (as root):
# alsactl -f /var/lib/alsa/asound.state store
It may be necessary configure ALSA again with alsamixer
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found .
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.
NOTE: the script is done by such way that it is incompatible with python3 (which is now shipped with ArchLinux) but tries to use it.
The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".
NOTE2: the script requires root acces, but running it via su/sudo is bogus. Run it via kdesu or gksu.
If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.
# export SDL_AUDIODRIVER=alsa
If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to /etc/asound.conf.
pcm.!default {
slave.pcm &softvol&
pcm.softvol {
type softvol
pcm &dmix&
name &Pre-Amp&
min_dB -5.0
max_dB 20.0
resolution 6
You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing plug with hw in the above configuration.
After the changes are loaded successfully, you will see a Pre-Amp section in alsamixer. You can adjust the levels there.
Note: Setting a high value for Pre-Amp can cause sound distortion, so adjust it according to the level that suits you.
You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing /etc/pm/sleep.d/90alsa and removing the line that says aplay -d 1 /dev/zero
Navigation menu

我要回帖

更多关于 开发板ping不通虚拟机 的文章

 

随机推荐