amixer和alsamixer使用说明
amixer和alsamixer使用说明
amixer和alsamixer说明
本文主要解答:
1. amixer与alsamixer的区别
2. amixer与alsamixer的使用
alsamixer与amixer的区别
alsamixer是Linux音频框架ALSA工具之一,用于配置音频各个参数;
alsamixer是基于文本图形界面的,可以在终端中显示.通过键盘的上下键,左右键等实现音量设置,开关操作等。
amixer,是alsamixer的文本模式,即命令行模式,以命令行的形式去配置声卡的各个选项,比如选择音频输入通道是Mic输入,还是Line输入。
alsamixer的使用
amixer的使用
[email protected]:~$ amixer -h
Usage: amixer [command]
Available options:
-h,--help this help
-c,--card N select the card
-D,--device N select the device, default 'default'
-d,--debug debug mode
-n,--nocheck do not perform range checking
-v,--version print version of this program
-q,--quiet be quiet
-i,--inactive show also inactive controls
-a,--abstract L select abstraction level (none or basic)
-s,--stdin Read and execute commands from stdin sequentially
-R,--raw-volume Use the raw value (default)
-M,--mapped-volume Use the mapped volume
Available commands:
scontrols show all mixer simple controls
scontents show contents of all mixer simple controls (default command)
sset sID P set contents for one mixer simple control
sget sID get contents for one mixer simple control
controls show all controls for given card
contents show contents of all controls for given card
cset cID P set control contents for one control
cget cID get control contents for one control
常用的命令:
amixer controls 用于查看音频系统提供的操作接口
amixer contents 用于查看接口配置参数
amixer cget + 接口函数
amixer cset + 接口函数 + 设置值
通常是先用cget/sget命令去查看接口,然后再用cset/sset命令设置所要设置的值;sget/sset相当于简化版,实现简单的参数设置,一般情况下使用scontrols ,scontents即可满足需求;
#./amixer scontrols
Simple mixer control 'Headphone',0
...
Simple mixer control 'Line In',0
Simple mixer control 'Left Capture Source',0
Simple mixer control 'Right Capture Source',0
...
#./amixer sget 'Left Capture Source',0
/media/sda1/bin_mips_alsa/mips-alsa/bin/amixer controls
/media/sda1/bin_mips_alsa/mips-alsa/bin/amixer cset numid=4,iface=MIXER,name='Speaker Playback Volume' 100
Simple mixer control 'Left Capture Source',0
Capabilities: enum
Items: 'Mic 1' 'Mic 2' 'Line' 'Mono In' 'Headphone' 'Speaker' 'Mono Out' 'Zh'
Item0: 'Mic 1'
如果想要修改对应设置,用amixer sset ,具体用法是:
amixer sset sID(控制字符串) P(支持的某个值)
其中sID,就是上面的Simple mixer control后面的那个字符串,比如 ‘Left Capture Source’ 而对其设置就是,
# ./amixer sset 'Left Capture Source',0 Line
Simple mixer control 'Left Capture Source',0
Capabilities: enum
Items: 'Mic 1' 'Mic 2' 'Line' 'Mono In' 'Headphone' 'Speaker' 'Mono Out' 'Zh'
Item0: 'Line'
# amixer controls
numid=3,iface=MIXER,name='Master Mode Switch'
numid=29,iface=MIXER,name='Master Mux'
numid=4,iface=MIXER,name='Master Quality Switch'
numid=2,iface=MIXER,name='Master Switch'
numid=1,iface=MIXER,name='Master Volume'
numid=7,iface=MIXER,name='PCM Mode Switch'
numid=6,iface=MIXER,name='PCM Switch'
numid=5,iface=MIXER,name='PCM Volume'
numid=21,iface=MIXER,name='Line Input Switch'
numid=16,iface=MIXER,name='Line Mode Switch'
numid=27,iface=MIXER,name='Line Mux'
# amixer contents
numid=3,iface=MIXER,name='Master Mode Switch'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'Common Buffer Off'
; Item #1 'Common Buffer On'
: values=0
# amixer cget numid=5,iface=MIXER,name='PCM Volume'
numid=5,iface=MIXER,name='PCM Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=27,step=0
: values=27,27
| dBscale-min=-40.50dB,step=1.50dB,mute=0
如上PCM音量最大设定值为27,假设想要设置为25,那么就用cset去设置:
# amixer cset numid=5,iface=MIXER,name='PCM Volume' 25
numid=5,iface=MIXER,name='PCM Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=27,step=0
: values=25,25
| dBscale-min=-40.50dB,step=1.50dB,mute=0
alsa及aplay用法
amixer和alsamixer使用说明相关教程