OSS (简体中文)
From ArchWiki
| i18n |
|---|
| English |
| 简体中文 |
Contents |
[edit] 简介
Open Sound System (OSS)www.opensound.com是一个可以工作在一些类unix系统上的具有商业支持的声音驱动,包括了 Linux, FreeBSD, 和 Solaris.
OSS驱动此前是私有的但是最近开放了源代码,这一点也不和以前的linux内核中的次质量的oss/free一样(it has nothing to do with the sub-quality OSS/free in early linux kernels.)
好处:
- 透明软件混合(mix)升级到支持18个虚拟声音设备,并且在内核空间(kernel space)内混合,(virtual mixer),这点不像ALSA驱动的dmix,那只是通过ALSA lib在用户空间(user-space)。
- 提前设置程序音量。
- 在某些集成声音芯片上具有更好的音质。
反方:
- 软件虚拟3D效果,混响效果,和均衡器还没有被加入到OSS v4的新混合引擎里面。
[edit] 安装
- 安装软件
- 获取打包文件:
- 解压这个压缩文件:
- tar -zxvf oss-filename.tar.gz
- 进入这个目录然后运行下列命令打包安装文件并进行安装:
- makepkg -i
注意:以普通用户运行这个命令,而不要使用sudo来取得root权限。
- 开启 oss-linux:
- 在/etc/rc.conf里面,添加 !soundcore 到 MODULES来禁用这个模块。
- 重启,用来清除ALSA的模块, 或者手动去掉soundcore模块以及依赖这个模块的所有模块
- 运行 /etc/rc.d/oss-linux start (也可能是 oss-linux-free), 或者添加到/etc/rc.conf里面的DAEMONS项中。
[edit] 配置
你的声卡不用配置就可以工作的很好
用来加载oss驱动的配置文件在/usr/lib/oss/conf下面。不要直接编辑这些文件,你应该去编辑/etc/modprobe.conf。每个在/usr/lib/oss/conf下的文件都以MODULE_NAME.conf命名,当你运行oss-linux的时候,这些配置都传递到modprobe来加载模块。所以以下两种方法实际上(与修改/usr/lib/oss/conf下文件)是在做一样的事情:
(/usr/lib/oss/conf/osscore.conf)
max_intrate=1000 src_quality=4
(/etc/modprobe.conf)
options osscore max_intrate=1000 src_quality=4
注意: 这只是一个列子而已,除非你知道你在干嘛,否则不推荐你这么做
你可以通过下面方法获得你使用的模块:运行 ossdetect -v 然后查看 /usr/lib/oss/etc/installed_drivers这个文件。
其他参数: 请看下面文件里面的内容
/usr/lib/oss/conf/osscore.conf /usr/lib/oss/conf/ossusb.conf /usr/lib/oss/conf/vmix.conf /usr/lib/oss/conf/YOUR_AUDIO_DRIVER.conf
[edit] 推荐
# 在第一声音设备上允许最大的音频流(streams)数量(18)。 # 添加一个反馈(loopback)(可能叫备份?)声音设备 options vmix vmix1_numoutputs=18 vmix1_numloops=1
[edit] 程序命令
- /etc/rc.d/oss-linux: oss-linux service.
- /etc/rc.d/oss-linux-free: same as above, but for the free version.
- ossinfo: show list of sound devices and their status; passing argument "-v9" to get details including which programs use them.
- ossmix: command-line mixer, where you can configure volume, recording source and special sound effects (surround, reverb, etc).
- ossxmix: same as ossmix except for that it provides a GUI using gtk2.
- savemixer: save your current mixer settings (need superuser) or restore them, called automatically when the oss-linux service is stopped.
- ossrecord: simple command-line recording program.
- ossplay: simple command-line playing program. Supports WAV, AU, VOC and a few other containers.
[edit] 问题以及解决
- 类似ALSA的,你需要降低main音量和PCM音量来一定程序上减少噪音(这根据你芯片情况而定。我使用vol=65,pcm=65,芯片为via8237)
- 看这里了解如何设定默认声卡,因为默认的选择不是最优的。
- 如果一个程序播放声音遇到困难, 4front的wiki里面可能有解决办法.
- 如果你有其他问题,尝试在这个地方搜索或者发帖: http://www.4front-tech.com/forum/
[edit] Skype 问题
有一个特殊版本的Skype 1.4 for OSS(QT静态编译),你可以从这里获得AUR. 一个2进制程序包可以从 skype's 下载页获取[1].
[edit] 小技巧
[edit] 与ALSA兼容
OSS为ALSA提供了2个兼容层(layers):内核和ALSA lib。内核模块("cuckoo")是100%兼容所有程序,但是不能和最新的OSS版本;oss里面的alsa虚拟库已经过时,我也不知道到哪里去获得最新版本。
你现在只能使用ALSA为oss提供的插件
- Install alsa-plugins
- Edit /etc/asound.conf:
pcm.oss {
type oss
device /dev/dsp
}
pcm.!default {
type oss
device /dev/dsp
}
ctl.oss {
type oss
device /dev/mixer
}
ctl.!default {
type oss
device /dev/mixer
}
这种方法对选择硬件声音设备设计的不好的程序无效(skype 1.3, gizmo, ..)。
[edit] 在OSS下使用多媒体键
想使用OSS v4来实现多媒体键上的"提高音量,降低音量,禁音,取消禁音"功能?
只需要写3个类似下面的"脚本"(我假设你已经安装bc软件):
lowervolume.sh:
VOL=$(ossmix | grep misc.pcm1 | awk '{print $4}' | awk -F : '{print $1}')
VOL=$(echo $VOL-2 | bc)
ossmix misc.pcm1 $VOL:$VOL
raisevolume.sh:
VOL=$(ossmix | grep misc.pcm1 | awk '{print $4}' | awk -F : '{print $1}')
VOL=$(echo $VOL+2 | bc)
ossmix misc.pcm1 $VOL:$VOL
mute.sh:
#!/bin/bash
VOLUME=$(cat $HOME/.volume)
if [ -z "$VOLUME" ]; then
VOLUME=$(ossmix | grep misc.pcm1 | awk '{print $4}' | awk -F : '{print $1}')
ossmix misc.pcm1 0:0
echo $VOLUME > $HOME/.volume
else
ossmix misc.pcm1 $VOLUME:$VOLUME
> $HOME/.volume
fi
如果是静音状态,这将会恢复以前的音量。第一次使用前运行一下:
touch $HOME/.volume
下面你需要chmod +x这几个脚本,然后在你桌面环境里面设置键盘键。
[edit] System-wide (software) equalizer effects
NOTES: This requires the use of the old softoss module (the predecessor of vmix) which may not be as good as vmix, wine and gstreamer do not play nice with softoss, and the module will not work with sample rates higher than 48khz.
We must do a few things to gain access to these effects.
- If you're running the oss-linux-free daemon right now, stop it by running (as root):
/etc/rc.d/oss-linux-free stop
- On builds 1015 and older, in /usr/lib/oss/etc/installed_drivers remove
vmix
- On 1016 and newer, you should instead pass "vmix_disabled=1" parameter to osscore (via /usr/lib/oss/conf/osscore.conf) to disable vmix.
- in /usr/lib/oss/etc/installed_drivers add
softoss
- in /etc/rc.d/oss-linux-free comment out lines 15 through 20 so that it looks kinda like this
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Starting OSS/Open source driver"
# start
/usr/sbin/soundon
if [ $? -gt 0 ]; then
stat_fail
else
grep '^softoss' /proc/modules >/dev/null 2>/dev/null
# if [ $? -eq 0 ]; then
# stat_busy "Replacing old \"softoss\" module with \"vmix\""
# rmmod softoss
# modprobe vmix
# sed -i 's/^softoss.*$/vmix/' /usr/lib/oss/etc/installed_drivers
# fi
add_daemon oss4
stat_done
fi
;;
stop)
stat_busy "Saving OSS mixer"
/usr/sbin/savemixer
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
grep '^"cuckoo"' /proc/modules >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
stat_busy "Removing \"cuckoo\" module"
rmmod \"cuckoo\"
fi
stat_busy "Stopping OSS/Open source driver"
/usr/sbin/soundoff
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon oss4
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
This keeps the oss-linux-free daemon from replacing softoss with vmix. (Very useful if you wish to switch between softoss and vmix.)
- start the daemon again (as root of course)
/etc/rc.d/oss-linux-free start
- If no errors are reported, then you may now see/use the effects with either ossmix or ossxmix with
ossmix -d1
or
ossxmix
- you must turn off bipass to actually use the effects
ossmix -d1 effects.eq.bypass OFF
or just uncheck bypass in ossxmix
- enjoy