系统集成了aplay和mplay,但这个两个播放器都没有设置音量的参数,为了调节音量,查到了amixer指令
查看help,以开阳1668为例,支持如下功能:
$ amixer -help
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 controls
numid=3,iface=MIXER,name='EQ Bass'
numid=4,iface=MIXER,name='EQ BassF0'
numid=5,iface=MIXER,name='EQ BassQ'
numid=6,iface=MIXER,name='EQ Middle'
numid=7,iface=MIXER,name='EQ MiddleF0'
numid=8,iface=MIXER,name='EQ MiddleQ'
numid=9,iface=MIXER,name='EQ Treble'
numid=10,iface=MIXER,name='EQ TrebleF0'
numid=11,iface=MIXER,name='EQ TrebleQ'
numid=1,iface=MIXER,name='Left Playback Volume'
numid=15,iface=MIXER,name='PA Fader-FL'
numid=16,iface=MIXER,name='PA Fader-FR'
numid=17,iface=MIXER,name='PA Fader-RL'
numid=18,iface=MIXER,name='PA Fader-RR'
numid=19,iface=MIXER,name='PA Fader-Sub1'
numid=20,iface=MIXER,name='PA Fader-Sub2'
numid=13,iface=MIXER,name='PA Input Select'
numid=14,iface=MIXER,name='PA Input-Full-Diff-Type Select'
numid=12,iface=MIXER,name='PA Input-Gain'
numid=24,iface=MIXER,name='PA Loudness'
numid=26,iface=MIXER,name='PA Loudness-F0 Select'
numid=25,iface=MIXER,name='PA Loudness-HiCut Select'
numid=27,iface=MIXER,name='PA Mixing-CH1 Switch'
numid=28,iface=MIXER,name='PA Mixing-CH2 Switch'
numid=29,iface=MIXER,name='PA Mixing-Input Select'
numid=21,iface=MIXER,name='PA Mute'
numid=22,iface=MIXER,name='PA Reset'
numid=30,iface=MIXER,name='PA Sub-Input Select'
numid=31,iface=MIXER,name='PA Sub-LPF-FC Select'
numid=32,iface=MIXER,name='PA Sub-LPF-Parse Select'
numid=33,iface=MIXER,name='PA Sub-Output Select'
numid=23,iface=MIXER,name='PA Volume'
numid=2,iface=MIXER,name='Right Playback Volume'
查看所有配置的值,可以通过这个查看:amixer contents
$ amixer contents
numid=3,iface=MIXER,name='EQ Bass'
; type=INTEGER,access=rw------,values=1,min=0,max=30,step=0
: values=15
numid=4,iface=MIXER,name='EQ BassF0'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'BASS_F0:60HZ'
; Item #1 'BASS_F0:80HZ'
; Item #2 'BASS_F0:100HZ'
; Item #3 'BASS_F0:120HZ'
: values=0
numid=5,iface=MIXER,name='EQ BassQ'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'BASS_Q:0.5'
; Item #1 'BASS_Q:1.0'
; Item #2 'BASS_Q:1.5'
; Item #3 'BASS_Q:2.0'
: values=0
numid=6,iface=MIXER,name='EQ Middle'
; type=INTEGER,access=rw------,values=1,min=0,max=30,step=0
: values=15
numid=7,iface=MIXER,name='EQ MiddleF0'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'MIDDLE_F0:0.5KHZ'
; Item #1 'MIDDLE_F0:1KHZ'
; Item #2 'MIDDLE_F0:1.5KHZ'
; Item #3 'MIDDLE_F0:2.5KHZ'
: values=0
numid=8,iface=MIXER,name='EQ MiddleQ'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'MIDDLE_Q:0.75'
; Item #1 'MIDDLE_Q:1.00'
; Item #2 'MIDDLE_Q:1.25'
; Item #3 'MIDDLE_Q:1.50'
: values=0
numid=9,iface=MIXER,name='EQ Treble'
; type=INTEGER,access=rw------,values=1,min=0,max=30,step=0
: values=15
numid=10,iface=MIXER,name='EQ TrebleF0'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'TREBLE_F0:7.5KHZ'
; Item #1 'TREBLE_F0:10KHZ'
; Item #2 'TREBLE_F0:12.5KHZ'
; Item #3 'TREBLE_F0:15KHZ'
: values=0
numid=11,iface=MIXER,name='EQ TrebleQ'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'TREBLE_Q:0.75'
; Item #1 'TREBLE_Q:1.25'
: values=0
numid=1,iface=MIXER,name='Left Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=127,step=0
: values=127
numid=15,iface=MIXER,name='PA Fader-FL'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=95
numid=16,iface=MIXER,name='PA Fader-FR'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=0
numid=17,iface=MIXER,name='PA Fader-RL'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=0
numid=18,iface=MIXER,name='PA Fader-RR'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=0
numid=19,iface=MIXER,name='PA Fader-Sub1'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=0
numid=20,iface=MIXER,name='PA Fader-Sub2'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=0
numid=13,iface=MIXER,name='PA Input Select'
; type=ENUMERATED,access=rw------,values=1,items=9
; Item #0 'A_SINGLE'
; Item #1 'B_SINGLE'
; Item #2 'C_SINGLE:BT'
; Item #3 'D_SINGLE:NAVI'
; Item #4 'E1_SINGLE:RADIO'
; Item #5 'E2_SINGLE:AUX'
; Item #6 'D_DIFF:D'
; Item #7 'E_FULL_DIFF:E1+E2'
; Item #8 'INPUT_SHORT:ALL'
: values=3
numid=14,iface=MIXER,name='PA Input-Full-Diff-Type Select'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'FULL_DIFF_TYPE:NEGATIVE INPUT'
; Item #1 'FULL_DIFF_TYPE:BIAS'
: values=0
numid=12,iface=MIXER,name='PA Input-Gain'
; type=INTEGER,access=rw------,values=1,min=0,max=16,step=0
: values=0
numid=24,iface=MIXER,name='PA Loudness'
; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
: values=0
numid=26,iface=MIXER,name='PA Loudness-F0 Select'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'LOUDNESS_F0:400HZ'
; Item #1 'LOUDNESS_F0:800HZ'
; Item #2 'LOUDNESS_F0:2400HZ'
: values=1
numid=25,iface=MIXER,name='PA Loudness-HiCut Select'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'HI_CUT:0'
; Item #1 'HI_CUT:1'
; Item #2 'HI_CUT:2'
; Item #3 'HI_CUT:3'
: values=0
numid=27,iface=MIXER,name='PA Mixing-CH1 Switch'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'ON'
; Item #1 'OFF'
: values=0
numid=28,iface=MIXER,name='PA Mixing-CH2 Switch'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'ON'
; Item #1 'OFF'
: values=0
numid=29,iface=MIXER,name='PA Mixing-Input Select'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'MIN'
; Item #1 'A_SINGLE'
; Item #2 'B_SINGLE'
: values=0
numid=21,iface=MIXER,name='PA Mute'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'OFF'
; Item #1 'ON'
: values=0
numid=22,iface=MIXER,name='PA Reset'
; type=ENUMERATED,access=rw------,values=1,items=1
; Item #0 'RESET'
: values=0
numid=30,iface=MIXER,name='PA Sub-Input Select'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'LOUDNESS'
; Item #1 'INPUT SELECTOR'
: values=0
numid=31,iface=MIXER,name='PA Sub-LPF-FC Select'
; type=ENUMERATED,access=rw------,values=1,items=6
; Item #0 'OFF'
; Item #1 '55HZ'
; Item #2 '85HZ'
; Item #3 '120HZ'
; Item #4 '160HZ'
; Item #5 'PASS'
: values=0
numid=32,iface=MIXER,name='PA Sub-LPF-Parse Select'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 '0'
; Item #1 '180'
: values=0
numid=33,iface=MIXER,name='PA Sub-Output Select'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'LPF'
; Item #1 'FRONT'
; Item #2 'REAR'
; Item #3 'SUBWOOFER'
: values=0
numid=23,iface=MIXER,name='PA Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=95,step=0
: values=60
numid=2,iface=MIXER,name='Right Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=127,step=0
: values=127
要用get系列命令去看懂有哪些接口,然后再去用set系列的命令,去设置对应你所要设置的值
amixer cget
amixer cset
获取当前音量
主音量
amixer cget numid=34,iface=MIXER,name='softmaster'
numid=34,iface=MIXER,name='softmaster'
; type=INTEGER,access=rw---RW-,values=2,min=0,max=127,step=0
: values=50,50
| dBscale-min=0.00dB,step=0.40dB,mute=0
左声道
amixer cget numid=1,iface=MIXER,name='Left Playback Volume'
numid=1,iface=MIXER,name='Left Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=127,step=0
: values=127
右声道
amixer cget numid=2,iface=MIXER,name='Right Playback Volume'
numid=2,iface=MIXER,name='Right Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=127,step=0
: values=127
设置音量
amixer cset numid=34,iface=MIXER,name='softmaster' 100
numid=34,iface=MIXER,name='softmaster'
; type=INTEGER,access=rw---RW-,values=2,min=0,max=127,step=0
: values=100,100
| dBscale-min=0.00dB,step=0.40dB,mute=0