ALSA(Advanced Linux Sound Architecture)
前言:
一般我在 PC 安裝音效卡方式是在 install 時,就讓系統自己去偵測,
有測到,人生是彩色的,沒測到,就算了 :~ 本篇不是討論在一般圖形
介面上安裝操作,純綷是苦力安裝方式,適合冒險犯難的人士為之。
Kernel driver:
由於舊的 OSS 音效方式不理想,所以現在改用 ALSA 方式, ALSA
功能較強大,缺點是,設定很麻煩!首先我們由 Kernel 下手,安裝一
下正確的驅動程式,我們看一下電腦上的音效卡是何方神聖:
# cat /proc/pci
......
Multimedia audio controller: VIA Technologies, Inc. VT82C686 AC97 Audio Controller
......
本範例是VIA的音效卡,所以我找了一下,是用這個 kernel module:
snd-via82xx,重編 Kernel 並載入 snd-via82xx ,先設一個設定檔
# echo "alias sound-slot-0 snd-via82xx" >> /etc/modprobe.conf
再來載入模組:
# modprobe snd-via82xx
如果沒問題,記得放入 /etc/modules.conf 內,免得每次重開機就要再
設一次:
# echo "snd-via82xx" >> /etc/modules.conf
再來就是為了讓有些只使用 OSS 方式的程式也能播放,你也要載入
snd-pcm-oss
# modprobe snd-pcm-oss
# echo "snd-pcm-oss" >> /etc/modules.conf #一樣是為了自動載入
安裝 ALSA 程式庫及工具:
查查看有沒有 /usr/lib/libasound.so.xxx 的檔,沒有的話要安裝套件
libalsa-xxx。工具程式則要 /bin/amixer 及 /bin/aplay ,前一個是設
定程式,後一個是播放程式,若無則安裝套件 alsa-utils-xxx ,最後
還要安裝必備的設定檔,放在 /usr/share/alsa ,若無,則安裝
libalsa-data-xxx 套件。
播放前準備:
一切就緒後,記得要打開音量控制,因為預設是「靜音」模式,很奇
怪的設定,播放前,先解除靜音模式:
# amixer set PCM 31 unmute
# amixer set Master 31 unmute
其中31是指音量大小,0~31代表0%~100%。
播放測試:
最後就是測試啦!
# /usr/bin/aplay /usr/share/sounds/KDE_Startup_new.wav
其他:
一些相關的 device:
# ll /dev/sound/
crw------- 1 thyme audio 14, 12 1月 1 1970 adsp
crw------- 1 thyme audio 14, 4 1月 1 1970 audio
crw------- 1 thyme audio 14, 3 1月 1 1970 dsp
crw------- 1 thyme audio 14, 0 1月 1 1970 mixer
crw------- 1 thyme audio 14, 1 1月 1 1970 sequencer
crw------- 1 thyme audio 14, 8 1月 1 1970 sequencer2
# ll /dev/snd/
crw------- 1 thyme audio 116, 0 1月 1 1970 controlC0
crw------- 1 thyme audio 116, 24 1月 1 1970 pcmC0D0c
crw------- 1 thyme audio 116, 16 1月 1 1970 pcmC0D0p
crw------- 1 thyme audio 116, 25 1月 1 1970 pcmC0D1c
crw------- 1 thyme audio 116, 1 1月 1 1970 seq
crw------- 1 thyme audio 116, 33 1月 1 1970 timer
# ll /dev/dsp /dev/adsp /dev/audio /dev/mixer /dev/sequencer*
lr-xr-xr-x 1 root root 10 5月 26 09:13 /dev/adsp -> sound/adsp
lr-xr-xr-x 1 root root 11 5月 26 09:13 /dev/audio -> sound/audio
lr-xr-xr-x 1 root root 9 5月 26 09:13 /dev/dsp -> sound/dsp
lr-xr-xr-x 1 root root 11 5月 26 09:13 /dev/mixer -> sound/mixer
lr-xr-xr-x 1 root root 15 5月 26 09:13 /dev/sequencer -> sound/sequencer
lr-xr-xr-x 1 root root 16 5月 26 09:13 /dev/sequencer2 -> sound/sequencer2
參考資料:
http://phorum.vbird.org/viewtopic.php?t=12205&highlight=alsa+amixer file:///usr/src/linux/Documentation/sound/alsa/OSS-Emulation.txt
file:///usr/src/linux/Documentation/sound/alsa/ALSA-Configuration.txt
file:///usr/share/doc/HOWTO/HTML/en/Alsa-sound/Alsa-sound.html
--
本文章可非營利自由轉載,需註明文章作者及來源。