FC2,FC3使用ALSA驱动Software mixing实现多音频流支持的简单方法
时间:2005-01-18
来源:互联网
在alsa sound matrix搜索得到自己声卡页面,
按照相应的指南修改/etc/modprobe.conf即可使用。
CCRMA的apt源:
# Name: Planet CCRMA #rpm http://ccrma.stanford.edu/planetccrma/apt fedora/3/i386 planetccrma planetcore # mirrors: IRCSM, Paris, France # rpm http://mirrors.ircam.fr/pub/planetccrma/apt fedora/2/i386 planetccrma planetcore rpm http://ccrma.stanford.edu/planetccrma/apt fedora/3/i386 planetccrma planetcore rpm-src http://ccrma.stanford.edu/planetccrma/apt fedora/3/i386 planetccrma planetcore
首先,apt安装alsa的包
# apt-get update # apt-get install alsa-driver alsa-lib,alsa-utils,alsa-oss
如果愿意装自己动手,
从alsa 网站下载alsa-driver,alsa-lib,alsa-utils,alsa-oss,alsa-tools
下载地址:ftp://ftp.alsa-project.org/pub/oss-l...-1.0.8.tar.bz2
解压后,编译安装:
编译安装的方法不详述了,
请参考相关的贴子。
注意一点,编译安装alsa-oss时,
#./configure --with-aoss=yes <--- 这个要加上 --->
我的声卡是VIA82C686A板载AC‘97(无关部分省略):
..... # ALSA portion alias char-major-116 snd alias snd-card-0 snd-via82xx # module options should go here # OSS/Free portion alias char-major-14 soundcore alias sound-slot-0 snd-card-0 # card #1 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
http://www.alsa-project.org/alsa-doc/
就是这个部分:
Choose manufacturer for more details all go Last update Thursday 06 January 2005 10:34 |
# /sbin/depmod -a 选择重新启动也可以 # /etc/init.d/alsasount stop # /etc/init.d/alsasound start 注意,执行上一步,在gnome桌面,因为会杀死音量控制小程序,可能会造成X退出。
最简单的
# cat ~/.asoundrc pcm.!default { type hw card 0 } ctl.!default { type hw card 0 }
上面的设置是不行的。
需要进行设置,
下面的设置供参考:
$ cat .asoundrc pcm.via82xx { type hw card 0 } ctl.via82xx { type hw card 0 } pcm.!default { type plug slave.pcm "dmixer" } pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 rate 44100 } bindings { 0 0 1 1 } } ctl.dmixer { type plug slave.pcm "dmixer" } pcm.mixin { type dsnoop ipc_key 5978293 # must be unique for all dmix plugins!!!! ipc_key_add_uid yes slave { pcm "hw:0,0" channels 2 period_size 1024 buffer_size 4096 rate 44100 periods 0 period_time 0 } bindings { 0 0 0 1 } }
请参考:
http://www.alsa-project.org/a lsa-do...module=Generic
Software mixing Software mixing is the ability to play multiple sound files or applications at the same time through the same device. There are many ways to have software mixing in the Linux environment. Usually it requires a server application such as ARTSD, ESD, JACK... The list is large and the apps can often be confusing to use. dmix These days we have a native plugin for ALSA called the dmix (direct mixing) plugin. It allows software mixing in an easy to use syntax and without the hassle of installing/understanding a new application first. A very interesting and potentially extremely useful aspect of this plugin is using it combined with the default plugin name. In theory this means all applications that have native ALSA support will share the sound device. In practice not many applications are able to take advantage of this functionality yet. However if you have time to test and report your findings to the application developers it is worth a try: pcm.!default { type plug slave.pcm "dmixer" } pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:1,0" period_time 0 period_size 1024 buffer_size 4096 rate 44100 } bindings { 0 0 1 1 } } ctl.dmixer { type hw card 0 } (To use it with your own name just change the word !default above) Now try: aplay -f cd -D default test.wav on multiple consoles. Some notes: The dmix PCM name is already defined in the global configuration file /usr/share/alsa/alsa.conf. - The default sample rate for this device is 48000Hz. If you would like to change it use: aplay -D"plug:'dmix:RATE=44100'" test.wav - An example command for dmix plugin to use 44100Hz sample-rate and hw:1,0 output device: aplay -Dplug:\'dmix:SLAVE=\"hw:1,0\",RATE=44100\' test.wav - The dmix PCM name is already defined in the global configuration file /usr/share/alsa/alsa.conf. Defaults are: SLAVE="hw:0,0",RATE=48000 NB the dmix plugin is not based on client/server architecture, but it writes directly to the soundcard's DMA buffer. There is no limit to the amount of instances that can be run at one time . dsnoop While the dmix plugin is for mixing multiple output(playback) streams together, if you want to use multiple input(capture) clients you need to use the dsnoop plugin: pcm.mixin { type dsnoop ipc_key 5978293 # must be unique for all dmix plugins!!!! ipc_key_add_uid yes slave { pcm "hw:0,0" channels 2 period_size 1024 buffer_size 4096 rate 44100 periods 0 period_time 0 } bindings { 0 0 0 1 } } |
最后说一点xmms的播放插件,
在gnome下,要选择libOSS.so,
在kde下,要选择libALSA.so,
同时可以配置插件,
选择音量控制不是PCM,
这样可以使得不同的程序有不同的播放音量。
如下面的贴图,
xmms和alsa使用不同音量,
可以各自调节。
好了,完成。
这时,你可以一边用xmms播放mp3、一边用mplayer看电影,或者一边听音乐、一边仍能接受系统消息,同时播放几个媒体文件等……怎么用,随你了。
前两天的叙述不准确,
忽视了~.asoundrc文件的重要性,可能对一些兄弟造成误导。
希望现在的步骤可以有所帮助。
foo41.jpg (44.0 KB, 253 次查看) | |
foo42.jpg (44.1 KB, 170 次查看) | |
Screenshot2.jpg (89.7 KB, 203 次查看) |
作者: aaccdd 发布时间: 2005-01-18
先顶再试──俺弄了一个多月了,都没弄好。
希望FC4时发行者解决此问题。
作者: ogog 发布时间: 2005-01-19
alsa-lib-1.0.6-3
alsa-utils-1.0.6-3
alsa-lib-devel-1.0.6-5
连driver都不是alsa的!FC3自带不是alsa的吗?上面的要全部装上吗?
作者: ogog 发布时间: 2005-01-19
sources里没有alsa-kmdl,alsa-driver,alsa-driver-devel
Screenshot-1.png (90.5 KB, 98 次查看) |
作者: ogog 发布时间: 2005-01-19
# ATrpms for Fedora Core 3
rpm http://apt.atrpms.net fedora/3/en/i386 at-stable
rpm-src http://apt.atrpms.net fedora/3/en/i386 at-stable
导入gpg-key:
# rpm --import http://www.atrpms.net/RPM-GPG-KEY.atrpms
更新apt软件库:
# apt-get update
# apt-get install alsa-driver
作者: aaccdd 发布时间: 2005-01-19
作者: waynef 发布时间: 2005-01-19
作者: Awei 发布时间: 2005-01-19
它的dev/下有dsp0,dsp1,dsp2,dsp3及mixer0,mixer1,mixer2,mixer3.
而FC3下只有一个dsp和一个mixer。
不知knoppix是如何弄出来的。
作者: ogog 发布时间: 2005-01-19
作者: aaccdd 发布时间: 2005-01-19
作者: aaccdd
安装完毕,需要/sbin/ldconfig
|
作者: waynef 发布时间: 2005-01-19
重新启动一下试试。
俺机子上还装有knoppix,它也是alsa-driver,多音频流很好用。 它的dev/下有dsp0,dsp1,dsp2,dsp3及mixer0,mixer1,mixer2,mixer3. 而FC3下只有一个dsp和一个mixer。 不知knoppix是如何弄出来的 |
debian sarge的多音频流支持就很好。
作者: aaccdd 发布时间: 2005-01-19
作者: waynef 发布时间: 2005-01-19
觉得 ATrpms 挺变态的,不敢用
作者: bbbush 发布时间: 2005-01-19
并且面板上调音量的小喇叭不见了,每次开机都要手动打开master音量控制,不知咋办好。
Screenshot-2.png (167.9 KB, 108 次查看) |
作者: ogog 发布时间: 2005-01-19
我在FC2下实验了一下,
也可以实现多音频播放,
如图:
foo41.jpg (86.2 KB, 100 次查看) |
作者: aaccdd 发布时间: 2005-01-19
虽然不起作用,但还是有一些改进,原来我在多媒体系统选择器里要选用esd并把一些程序设置为使用esd才可以实现多音频流,但现在多媒体系统选择器选用alsa,具体的程序只要用esd就可以了。总之还是得用esd。
作者: waynef 发布时间: 2005-01-19
机器的声卡不同,要做相应的修改。
具体的程序只要用esd就可以了。总之还是得用esd。 |
附上一张FC3的效果图
Screenshot1.jpg (75.0 KB, 70 次查看) |
作者: aaccdd 发布时间: 2005-01-19
我说的默认的/etc/modprobe.conf是指是否安装完系统后自动生成的,不需要自己添加其他内容。
作者: waynef 发布时间: 2005-01-19
一点问题没有
作者: aaccdd 发布时间: 2005-01-19
那我要启用这个新内核才行吗?
作者: ogog 发布时间: 2005-01-19
Planet CCRMA provides a version (actually two at the time of this writing) of the Linux kernel with two key differences from the standard Fedora Core kernel: better low latency performace and the inclusion of the realtime Linux Security Module, which will enable you to run programs like Jack with realtime privileges from a normal non-root account.
CCRMA的内核同标准FC的内核相比,有更好的低延迟表现,并且包含实时安全模块,使得普通用户得到运行Jack等程序的实时权限。
作者: aaccdd 发布时间: 2005-01-19
作者: ogog 发布时间: 2005-01-20
能不能再详细一点啊,似乎步骤不可重复的说……
作者: bbbush 发布时间: 2005-01-20
我的Intel810 AC'97好象不行
谁弄好了说一声
作者: storm999 发布时间: 2005-01-20
今天做了更新,
重点给出了一份~/.asoudrc文件的例子,
请楼上的兄弟再试验一下。
作者: aaccdd 发布时间: 2005-01-20
[root@jackycom ~]# rpm -qa |grep alsa clalsadrv-1.0.1-1.rhfc3.ccrma alsa-utils-1.0.7-1.cvs.rhfc3.ccrma alsa-driver-1.0.7-1.cvs.rhfc3.ccrma kernel-module-alsa-2.6.10-2.1.ll.rhfc3.ccrma-1.0.7-1.cvs.rhfc3.ccrma alsa-lib-1.0.7-1.cvs.rhfc3.ccrma alsa-lib-devel-1.0.7-1.cvs.rhfc3.ccrma alsa-oss-1.0.7-1.cvs.rhfc3.ccrma
[yuan@jackycom ~]$ cat .asoundrc pcm.!default { type plug slave.pcm "dmixer" } pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 4096 rate 44100 } bindings { 0 0 1 1 } } ctl.dmixer { type hw card 0 }
下面是一些试验的结果。“dmix 起作用”,就是大家最希望得到的结果,成功做到同时发声
1. 用 mplayer 试验的结果,默认 mplayer 会使用 alsa 驱动,但 dmix 不起作用,但是只要用 mplayer -ao alsa 或者将 ao=alsa 写入 $HOME/.mplayer/config 那么 dmix 就可以起作用了。是否运行 aoss 都没有关系,是否设置环境变量也没有关系,是否加载 snd-pcm-oss 驱动也没有关系。
2. 用 bmp 试验的结果,默认的声音驱动是 alsa,且配置为 hw:0.0 时,dmix 不起作用。用 alsa 且配置为 default 时,dmix 可以起作用。用 aoss beep-media-player 方式启动,且声音驱动使用 oss,这时 dmix 可以起作用。
3. 用 xmms 试验的结果,默认的声音驱动是 alsa 时,dmix 可以起作用,但是 oss 时不起作用。用 aoss xmms 方式启动,那么 dmix 总可以起作用。
4. 用 realplay 试验的结果,默认总是 oss,只有用 aoss realplay 方式启动时 dmix 才起作用。
5. 用 rhythmbox-gstreamer 试验的结果,默认 gstreamer 使用 alsa 流水线,dmix 可以起作用
6. 用 gaim 试验的结果,默认的声音驱动是 “自动”,不必做任何设置,dmix 就可以起作用。
7. 用 gxine 试验的结果,输出插件不知道是什么,默认是 stereo,dmix 可以起作用
综上所述,我们可以得到这样的结论,
1. 当应用程序使用 alsa 时,如果符合 alsa 编程的规范 (默认访问虚拟设备 default),那么只要 asoundrc 文件设置正确,dmix 就可以正常工作,这是 gaim 的情况,以及使用 alsa 输出驱动且配置为 default 的 bmp/xmms。还有 gstreamer 的 alsa 输出流水线 (包括 rhythmbox 等很多程序是使用 gstreamer 框架的)。不必设置其他内容,也不必以特殊方式启动。
2. 当应用程序使用 alsa 但不规范时 (应用程序直接访问 hw:0.0 而不是虚拟设备 default),那么 dmix 总是不起作用。就好像没有设置 -ao alsa 时的 mplayer,以及使用 alsa 输出插件且配置为 hw:0.0 的 bmp/xmms
3. 当应用程序使用 oss 时,必须使用 aoss 方式启动,dmix 才能正常工作。因为运行 aoss 时,脚本中会自动设置 LD_PRELOAD,因此不必再设置其他值。这是使用 oss 输出插件 bmp/xmms 的情况,还有 realplay 的情况。
4. 仍然解释不了的是 aoss mplayer -ao oss 这一句不起作用,也许是 mplayer 本身的问题,它似乎一定要直接访问 /dev/dsp
这种方法以前就有,artsd 系统包括一个 artsdsp 命令,用法和这里的 aoss 几乎完全一样,如果看看程序 /usr/bin/artsdsp 的话,会发现它的结构和 /usr/bin/aoss 也是一样的,首先设定 LD_PRELOAD,然后再执行程序。artsdsp 和 aoss 都是为那些只提供 oss 输出驱动的程序准备的。在那些程序访问声卡时,LD_PRELOAD 设定的库就开始发挥作用,它们将对声卡 /dev/dsp 的访问进行重定向,合并到一起。artsdsp 重定向之后,送到了 artsd,而 aoss 重定向之后,送到了 dmix。
我觉得,它们的区别在于 alsa 的 dmix 采用库的方式实现,比 artsd 的服务器进程要灵活。在 alsa-project 的网站上说,除了 dmix,也可以用 jack 实现同样的功能。有时间的话,可以再试一试。另外我只在 gnome 中进行了试验。在 kde 中,大概有不同的处理办法,比如把 artsd 关掉?
对于 aaccdd 的设置步骤,我觉得设置 LD_PRELOAD 已经没有必要了,只要设置 $HOME/.asoundrc 就可以。另外,使用 alias 是一个好主意,但是从命令行启动这些程序还是不现实,如果这些程序都支持 alsa 并且程序比较规范的话,事情就简单多了。
为了使用 CCRMA 的 alsa 驱动,还有一个地方需要注意,就是在 /etc/sysctl.conf 中最好有这样一句
# Controls max frequency available for normal user, need by mplayer, etc. dev.rtc.max-user-freq = 1024
另外还有一点,大家在调整完音量后,有没有执行过 alsactl store 命令呢?如果音量无法保存,不妨试试这个命令。要以 root 身份执行它。或者,执行一次 service alsasound restart 会更好。然后,再执行 chkconfig alsasound on,让系统在启动时加载音量
下面这个,是在 http://forums.gentoo.org/viewtopic.php?t=168223 看到的一篇很不错的帖子中提到的,讲到了对 nforce2 主板如何进行设置,声卡也是 snd_intel8x0。他的 $HOME/.asoundrc 如下,区别是 buffer_size 以及将 dsp0 也设置为 dmixer。另外大约是在设置 default 禁用后,又再次将 default 设置为 dmixer,但是我没发现什么特殊效果,也许是他写错了。配置文件的意思,大约是声卡可以设置多个别名吧?因为发现 mplayer -ao alsa:device=dsp0 这样的用法是可以的。
pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 rate 44100 } bindings { 0 0 1 1 } } pcm.dsp0 { type plug slave.pcm "dmixer" } pcm.!default { type plug slave.pcm "dmixer" } pcm.default { type plug slave.pcm "dmixer" } ctl.mixer0 { type hw card 0 }
在那篇帖子的跟帖中也提到了 mplayer 的问题。还有很长的一篇帖子在 http://forums.gentoo.org/viewtopic.php?t=122076
在那些跟帖中,还有一篇提到了,这些设置可以写到 /etc/asound.conf 文件中,这样可以全局有效,不必为每个用户都配置一次。也许与此有关的工具马上就会出现。最后,同样的配置文件似乎适用于所有不支持硬件多音频流的情况,并不与硬件类型相关,cmedia 8738 和 Analog Devices AD1980 也可以用
-
作者: bbbush 发布时间: 2005-01-21
俺也要试!
那版主要加点精哦!
作者: ogog 发布时间: 2005-01-21
~/.bashrc中的两条都不必了,
更新时没有去掉。
顶楼的贴子中~/.asoundrc的配置,
是对xmms直接调用有效的。
~/.asoundrc文件,是可以根据具体情况修改的,
参考alsa-project文档asoundrc的介绍。
如果要省事用alsa网站的例子,
要想发挥alsa的作用,就要自己摸索哦。
我给出的配置文件只能作为一个例子,
对于与我机器配置不同的则不能照抄了。
对于max-user-freq的问题,
我以为在配置mplayer时就应该想到,
所以忽略了。
谢谢bbbush的总结、指正。
希望我的抛砖引玉,能够引起兄弟们的讨论,
最好有条件的兄弟都能测试一下,
这个问题得到比较满意的解决,以后就不必再为这个问题烦心了。
PS:我的初衷是试图解决midi设备无法使用的问题,现在多音频能用了,但是midi仍然不行,郁闷啊。
作者: aaccdd 发布时间: 2005-01-21
我的intel8x0已经搞定, 向大家推荐
作者: storm999 发布时间: 2005-01-21
怎么解释这些东东
pcm.default 是应用程序一般会默认使用的输出设备,但是怎么知道应用程序一般会使用的输入设备是 pcm.mixin 呢,这里是不是有编程上的约定,还是在使用需要输入的程序时,必须设置输入设备为 mixin 才可以?
第二个问题就是 hw:0.0 是输出,hw:1.0 是输入?还是 hw:0.1 是输入?你的这个文件内容是什么样子的?
[root@jackycom asound]# cat /proc/asound/pcm 00-00: Intel ICH : Intel 82801BA-ICH2 : playback 1 : capture 1 00-01: Intel ICH - MIC ADC : Intel 82801BA-ICH2 - MIC ADC : capture 1
作者: bbbush 发布时间: 2005-01-21
Plugin: dsnoop
This plugin splits one capture stream to more. It works the reverse way of dmix plugin, reading the shared capture buffer from many clients concurrently. The meaning of parameters below are almost identical with dmix plugin.
pcm.name { type dsnoop # Direct snoop ipc_key INT # unique IPC key ipc_key_add_uid BOOL # add current uid to unique IPC key ipc_perm INT # IPC permissions (octal, default 0600) slave STR # or slave { # Slave definition pcm STR # slave PCM name # or pcm { } # slave PCM definition format STR # format definition rate INT # rate definition channels INT period_time INT # in usec # or period_size INT # in bytes buffer_time INT # in usec # or buffer_size INT # in bytes periods INT # when buffer_size or buffer_time is not specified } bindings { # note: this is client independent!!! N INT # maps slave channel to client channel N } slowptr BOOL # slow but more precise pointer updates } |
作者: aaccdd 发布时间: 2005-01-21
http://alsa.opensrc.org/index.php?page=DmixPlugin
http://alsa.opensrc.org/index.php?pa...nd+dirty+HOWTO
作者: eddy 发布时间: 2005-01-21
还学到了 asym 插件,可以将 dmix 和 snoop 结合起来的
还有,dsp0 和 mixer0 原来是为 oss 准备的啊
但是还是不知道 binding 还有硬件的数字怎么算,aaccdd 你在 /proc/asound/pcm 的那个文件内容是什么?
作者: bbbush 发布时间: 2005-01-22
作者: ogog 发布时间: 2005-01-22
作者: flowing 发布时间: 2005-01-23
不过找不到alsa-oss。
呵呵!我的系统多音频也不行。
作者: emylekao 发布时间: 2005-01-23
安装完成FC3后有一下相关软件:
# rpm -qa|grep alsa
alsa-lib-1.0.6-3
alsa-utils-1.0.6-3
alsa-lib-devel-1.0.6-3
alsa-driver应该在内核里面了吧。
可是,无法实现多音频流,不知道怎么回事。哪位高人解决了这个问题,帮帮指点一二。
作者: emylekao 发布时间: 2005-01-23
只是开了任一款播放器,LumaQQ和flashplayer插件不能发声。
Screenshot.png (88.8 KB, 34 次查看) |
作者: ogog 发布时间: 2005-01-23
作者: chen1960 发布时间: 2005-01-23
作者: 冷风 发布时间: 2005-01-25
作者: 冷风
好像realplayer还是不行
|
在桌面建了个启动器,用aoss realplay启动。
作者: ogog 发布时间: 2005-01-26
系统声音,如果是kde:选择Enlightement sound daemon;
如果是gnome,修改/etc/esd.conf
[esd] auto_spawn=1 spawn_options=-terminate -nobeeps -as 2 -d default <========= here spawn_wait_ms=100 |
作者: aaccdd 发布时间: 2005-01-26
大家帮我看看吧。
pcm.!default {
type plug
slave.pcm "dmixer"
}
ctl.ens1370 {
type hw
card 0
}
pcm.ens1370 {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
pcm.mixin {
type dsnoop
ipc_key 5978293 # must be unique for all dmix plugins!!!!
ipc_key_add_uid yes
slave {
pcm "hw:0,0"
channels 2
period_size 1024
buffer_size 4096
rate 44100
periods 0
period_time 0
}
bindings {
0 0
0 1
}
}
pcm.dsp0 {
type plug
slave.pcm "dmixer"
}
# or:
# pcm.dsp0 pcm.default
# if "default" hasn't been redefined
ctl.mixer0 {
type hw
card 0
}
作者: snoopyxp 发布时间: 2005-01-29
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
作者: ogog 发布时间: 2005-01-29
实现多音频流啦。
不过我还是只会用aoss,看了好多资料,还是看不懂怎么让程序自动使用alsa。
作者: lincomet 发布时间: 2005-01-30
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28