amixer,aplay,arecord交叉编译及使用

时间:2021-02-01 14:57:34

一.amixer用于控制设置 

amixer的帮助提示信息

Usage: amixer <options> [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

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


主要用到的命令参数有

controls:列出控制项

contents:列出控制上下文(也就是控制项和值)

cset cID P:设置控制项值

cget cID:获取设置项值

使用方法:

1.先amixer controls列出所有控制项

numid=1,iface=MIXER,name='PCM Playback Volume'
numid=22,iface=MIXER,name='Line DAC Playback Volume'
numid=20,iface=MIXER,name='Line Line2 Bypass Volume'
numid=21,iface=MIXER,name='Line PGA Bypass Volume'
numid=32,iface=MIXER,name='Line Playback Switch'
numid=25,iface=MIXER,name='Mono DAC Playback Volume'
numid=23,iface=MIXER,name='Mono Line2 Bypass Volume'
numid=66,iface=MIXER,name='Mono Mixer DACL1 Switch'
numid=69,iface=MIXER,name='Mono Mixer DACR1 Switch'
numid=64,iface=MIXER,name='Mono Mixer Line2L Bypass Switch'
numid=67,iface=MIXER,name='Mono Mixer Line2R Bypass Switch'
numid=65,iface=MIXER,name='Mono Mixer PGAL Bypass Switch'
numid=68,iface=MIXER,name='Mono Mixer PGAR Bypass Switch'
numid=24,iface=MIXER,name='Mono PGA Bypass Volume'
numid=33,iface=MIXER,name='Mono Playback Switch'
numid=39,iface=MIXER,name='ADC HPF Cut-off'
numid=36,iface=MIXER,name='AGC Switch'
numid=28,iface=MIXER,name='HP DAC Playback Volume'
numid=26,iface=MIXER,name='HP Line2 Bypass Volume'
numid=27,iface=MIXER,name='HP PGA Bypass Volume'
numid=34,iface=MIXER,name='HP Playback Switch'
numid=31,iface=MIXER,name='HPCOM DAC Playback Volume'
numid=29,iface=MIXER,name='HPCOM Line2 Bypass Volume'
numid=30,iface=MIXER,name='HPCOM PGA Bypass Volume'
numid=35,iface=MIXER,name='HPCOM Playback Switch'
numid=101,iface=MIXER,name='Left DAC Mux'
numid=60,iface=MIXER,name='Left HP Mixer DACL1 Switch'
numid=10,iface=MIXER,name='Left HP Mixer DACR1 Playback Volume'
numid=63,iface=MIXER,name='Left HP Mixer DACR1 Switch'
numid=58,iface=MIXER,name='Left HP Mixer Line2L Bypass Switch'
numid=61,iface=MIXER,name='Left HP Mixer Line2R Bypass Switch'
numid=8,iface=MIXER,name='Left HP Mixer Line2R Bypass Volume'
numid=59,iface=MIXER,name='Left HP Mixer PGAL Bypass Switch'
numid=62,iface=MIXER,name='Left HP Mixer PGAR Bypass Switch'
numid=9,iface=MIXER,name='Left HP Mixer PGAR Bypass Volume'
numid=48,iface=MIXER,name='Left HPCOM Mixer DACL1 Switch'
numid=16,iface=MIXER,name='Left HPCOM Mixer DACR1 Playback Volume'
numid=51,iface=MIXER,name='Left HPCOM Mixer DACR1 Switch'
numid=46,iface=MIXER,name='Left HPCOM Mixer Line2L Bypass Switch'
numid=49,iface=MIXER,name='Left HPCOM Mixer Line2R Bypass Switch'
numid=14,iface=MIXER,name='Left HPCOM Mixer Line2R Bypass Volume'
numid=47,iface=MIXER,name='Left HPCOM Mixer PGAL Bypass Switch'
numid=50,iface=MIXER,name='Left HPCOM Mixer PGAR Bypass Switch'
numid=15,iface=MIXER,name='Left HPCOM Mixer PGAR Bypass Volume'
numid=100,iface=MIXER,name='Left HPCOM Mux'
numid=78,iface=MIXER,name='Left Line Mixer DACL1 Switch'
numid=4,iface=MIXER,name='Left Line Mixer DACR1 Playback Volume'
numid=81,iface=MIXER,name='Left Line Mixer DACR1 Switch'
numid=76,iface=MIXER,name='Left Line Mixer Line2L Bypass Switch'
numid=79,iface=MIXER,name='Left Line Mixer Line2R Bypass Switch'
numid=2,iface=MIXER,name='Left Line Mixer Line2R Bypass Volume'
numid=77,iface=MIXER,name='Left Line Mixer PGAL Bypass Switch'
numid=80,iface=MIXER,name='Left Line Mixer PGAR Bypass Switch'
numid=3,iface=MIXER,name='Left Line Mixer PGAR Bypass Volume'
numid=92,iface=MIXER,name='Left Line1L Mux'
numid=91,iface=MIXER,name='Left Line1R Mux'
numid=90,iface=MIXER,name='Left Line2L Mux'
numid=93,iface=MIXER,name='Left PGA Mixer Line1L Switch'
numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'
numid=95,iface=MIXER,name='Left PGA Mixer Line2L Switch'
numid=96,iface=MIXER,name='Left PGA Mixer Mic3L Switch'
numid=97,iface=MIXER,name='Left PGA Mixer Mic3R Switch'
numid=38,iface=MIXER,name='PGA Capture Switch'
numid=37,iface=MIXER,name='PGA Capture Volume'
numid=99,iface=MIXER,name='Right DAC Mux'
numid=13,iface=MIXER,name='Right HP Mixer DACL1 Playback Volume'
numid=54,iface=MIXER,name='Right HP Mixer DACL1 Switch'
numid=57,iface=MIXER,name='Right HP Mixer DACR1 Switch'
numid=52,iface=MIXER,name='Right HP Mixer Line2L Bypass Switch'
numid=11,iface=MIXER,name='Right HP Mixer Line2L Bypass Volume'
numid=55,iface=MIXER,name='Right HP Mixer Line2R Bypass Switch'
numid=53,iface=MIXER,name='Right HP Mixer PGAL Bypass Switch'
numid=12,iface=MIXER,name='Right HP Mixer PGAL Bypass Volume'
numid=56,iface=MIXER,name='Right HP Mixer PGAR Bypass Switch'
numid=19,iface=MIXER,name='Right HPCOM Mixer DACL1 Playback Volume'
numid=42,iface=MIXER,name='Right HPCOM Mixer DACL1 Switch'
numid=45,iface=MIXER,name='Right HPCOM Mixer DACR1 Switch'
numid=40,iface=MIXER,name='Right HPCOM Mixer Line2L Bypass Switch'
numid=17,iface=MIXER,name='Right HPCOM Mixer Line2L Bypass Volume'
numid=43,iface=MIXER,name='Right HPCOM Mixer Line2R Bypass Switch'
numid=41,iface=MIXER,name='Right HPCOM Mixer PGAL Bypass Switch'
numid=18,iface=MIXER,name='Right HPCOM Mixer PGAL Bypass Volume'
numid=44,iface=MIXER,name='Right HPCOM Mixer PGAR Bypass Switch'
numid=98,iface=MIXER,name='Right HPCOM Mux'
numid=7,iface=MIXER,name='Right Line Mixer DACL1 Playback Volume'
numid=72,iface=MIXER,name='Right Line Mixer DACL1 Switch'
numid=75,iface=MIXER,name='Right Line Mixer DACR1 Switch'
numid=70,iface=MIXER,name='Right Line Mixer Line2L Bypass Switch'
numid=5,iface=MIXER,name='Right Line Mixer Line2L Bypass Volume'
numid=73,iface=MIXER,name='Right Line Mixer Line2R Bypass Switch'
numid=71,iface=MIXER,name='Right Line Mixer PGAL Bypass Switch'
numid=6,iface=MIXER,name='Right Line Mixer PGAL Bypass Volume'
numid=74,iface=MIXER,name='Right Line Mixer PGAR Bypass Switch'
numid=84,iface=MIXER,name='Right Line1L Mux'
numid=83,iface=MIXER,name='Right Line1R Mux'
numid=82,iface=MIXER,name='Right Line2R Mux'
numid=86,iface=MIXER,name='Right PGA Mixer Line1L Switch'
numid=85,iface=MIXER,name='Right PGA Mixer Line1R Switch'
numid=87,iface=MIXER,name='Right PGA Mixer Line2R Switch'
numid=88,iface=MIXER,name='Right PGA Mixer Mic3L Switch'
numid=89,iface=MIXER,name='Right PGA Mixer Mic3R Switch'

2.如果对控制项不熟悉或者想查看当前的所有配置可以使用amixer contents

numid=1,iface=MIXER,name='PCM Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
: values=64,64
| dBscale-min=-63.50dB,step=0.50dB,mute=0
numid=22,iface=MIXER,name='Line DAC Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=20,iface=MIXER,name='Line Line2 Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=21,iface=MIXER,name='Line PGA Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=32,iface=MIXER,name='Line Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=25,iface=MIXER,name='Mono DAC Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=23,iface=MIXER,name='Mono Line2 Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=66,iface=MIXER,name='Mono Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=69,iface=MIXER,name='Mono Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=64,iface=MIXER,name='Mono Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=67,iface=MIXER,name='Mono Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=65,iface=MIXER,name='Mono Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=68,iface=MIXER,name='Mono Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=24,iface=MIXER,name='Mono PGA Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=33,iface=MIXER,name='Mono Playback Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=39,iface=MIXER,name='ADC HPF Cut-off'
; type=ENUMERATED,access=rw------,values=2,items=4
; Item #0 'Disabled'
; Item #1 '0.0045xFs'
; Item #2 '0.0125xFs'
; Item #3 '0.025xFs'
: values=0,0
numid=36,iface=MIXER,name='AGC Switch'
; type=BOOLEAN,access=rw------,values=2
: values=off,off
numid=28,iface=MIXER,name='HP DAC Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=26,iface=MIXER,name='HP Line2 Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=27,iface=MIXER,name='HP PGA Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=34,iface=MIXER,name='HP Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=31,iface=MIXER,name='HPCOM DAC Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=29,iface=MIXER,name='HPCOM Line2 Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=30,iface=MIXER,name='HPCOM PGA Bypass Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=118,step=0
: values=71,71
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=35,iface=MIXER,name='HPCOM Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=101,iface=MIXER,name='Left DAC Mux'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'DAC_L1'
; Item #1 'DAC_L3'
; Item #2 'DAC_L2'
: values=2
numid=60,iface=MIXER,name='Left HP Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=10,iface=MIXER,name='Left HP Mixer DACR1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=63,iface=MIXER,name='Left HP Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=58,iface=MIXER,name='Left HP Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=61,iface=MIXER,name='Left HP Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=8,iface=MIXER,name='Left HP Mixer Line2R Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=59,iface=MIXER,name='Left HP Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=62,iface=MIXER,name='Left HP Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=9,iface=MIXER,name='Left HP Mixer PGAR Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=48,iface=MIXER,name='Left HPCOM Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=16,iface=MIXER,name='Left HPCOM Mixer DACR1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=51,iface=MIXER,name='Left HPCOM Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=46,iface=MIXER,name='Left HPCOM Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=49,iface=MIXER,name='Left HPCOM Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=14,iface=MIXER,name='Left HPCOM Mixer Line2R Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=47,iface=MIXER,name='Left HPCOM Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=50,iface=MIXER,name='Left HPCOM Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=15,iface=MIXER,name='Left HPCOM Mixer PGAR Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=100,iface=MIXER,name='Left HPCOM Mux'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'differential of HPLOUT'
; Item #1 'constant VCM'
; Item #2 'single-ended'
: values=0
numid=78,iface=MIXER,name='Left Line Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=4,iface=MIXER,name='Left Line Mixer DACR1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=81,iface=MIXER,name='Left Line Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=76,iface=MIXER,name='Left Line Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=79,iface=MIXER,name='Left Line Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=2,iface=MIXER,name='Left Line Mixer Line2R Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=77,iface=MIXER,name='Left Line Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=80,iface=MIXER,name='Left Line Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=3,iface=MIXER,name='Left Line Mixer PGAR Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=92,iface=MIXER,name='Left Line1L Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=91,iface=MIXER,name='Left Line1R Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=90,iface=MIXER,name='Left Line2L Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=93,iface=MIXER,name='Left PGA Mixer Line1L Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=95,iface=MIXER,name='Left PGA Mixer Line2L Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=96,iface=MIXER,name='Left PGA Mixer Mic3L Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=97,iface=MIXER,name='Left PGA Mixer Mic3R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=38,iface=MIXER,name='PGA Capture Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=37,iface=MIXER,name='PGA Capture Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=119,step=0
: values=32,32
| dBscale-min=0.00dB,step=0.50dB,mute=0
numid=99,iface=MIXER,name='Right DAC Mux'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'DAC_R1'
; Item #1 'DAC_R3'
; Item #2 'DAC_R2'
: values=2
numid=13,iface=MIXER,name='Right HP Mixer DACL1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=54,iface=MIXER,name='Right HP Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=57,iface=MIXER,name='Right HP Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=52,iface=MIXER,name='Right HP Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=11,iface=MIXER,name='Right HP Mixer Line2L Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=55,iface=MIXER,name='Right HP Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=53,iface=MIXER,name='Right HP Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=12,iface=MIXER,name='Right HP Mixer PGAL Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=56,iface=MIXER,name='Right HP Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=19,iface=MIXER,name='Right HPCOM Mixer DACL1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=42,iface=MIXER,name='Right HPCOM Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=45,iface=MIXER,name='Right HPCOM Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=40,iface=MIXER,name='Right HPCOM Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=17,iface=MIXER,name='Right HPCOM Mixer Line2L Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=116
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=43,iface=MIXER,name='Right HPCOM Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=41,iface=MIXER,name='Right HPCOM Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=18,iface=MIXER,name='Right HPCOM Mixer PGAL Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=44,iface=MIXER,name='Right HPCOM Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=98,iface=MIXER,name='Right HPCOM Mux'
; type=ENUMERATED,access=rw------,values=1,items=5
; Item #0 'differential of HPROUT'
; Item #1 'constant VCM'
; Item #2 'single-ended'
; Item #3 'differential of HPLCOM'
; Item #4 'external feedback'
: values=0
numid=7,iface=MIXER,name='Right Line Mixer DACL1 Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=72,iface=MIXER,name='Right Line Mixer DACL1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=75,iface=MIXER,name='Right Line Mixer DACR1 Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=70,iface=MIXER,name='Right Line Mixer Line2L Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=5,iface=MIXER,name='Right Line Mixer Line2L Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=73,iface=MIXER,name='Right Line Mixer Line2R Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=71,iface=MIXER,name='Right Line Mixer PGAL Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=6,iface=MIXER,name='Right Line Mixer PGAL Bypass Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=118,step=0
: values=118
| dBscale-min=-59.00dB,step=0.50dB,mute=1
numid=74,iface=MIXER,name='Right Line Mixer PGAR Bypass Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=84,iface=MIXER,name='Right Line1L Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=83,iface=MIXER,name='Right Line1R Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=82,iface=MIXER,name='Right Line2R Mux'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'single-ended'
; Item #1 'differential'
: values=0
numid=86,iface=MIXER,name='Right PGA Mixer Line1L Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=85,iface=MIXER,name='Right PGA Mixer Line1R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=87,iface=MIXER,name='Right PGA Mixer Line2R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=88,iface=MIXER,name='Right PGA Mixer Mic3L Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=89,iface=MIXER,name='Right PGA Mixer Mic3R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off

3.查看获取某个设置项的值用amixer cget  +控制参数

这里控制参数直接复制amixer controls打印出来的数据就行

类似numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'

root@dvr:/# amixer cget numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'
numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off

4.根据控制参数类型设置控制参数使用amixer cset +控制参数+" "+参数

记住要用空格隔开控制参数和参数

root@dvr:/# amixer cset numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch' on
numid=94,iface=MIXER,name='Left PGA Mixer Line1R Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on

5.参数

values表示数值对于volume之类的是具体的数字,在上下文菜单中有显示数值的范围,

对于swith之类的表示开关一般是on或off

 

 二、aplay和arecord用于播放和记录

arecord帮助提示信息

Usage: arecord [OPTION]... [FILE]...

-h, --help help
--version print current version
-l, --list-devices list all soundcards and digital audio devices
-L, --list-pcms list device names
-D, --device=NAME select PCM by name
-q, --quiet quiet mode
-t, --file-type TYPE file type (voc, wav, raw or au)
-c, --channels=# channels
-f, --format=FORMAT sample format (case insensitive)
-r, --rate=# sample rate
-d, --duration=# interrupt after # seconds
-M, --mmap mmap stream
-N, --nonblock nonblocking mode
-F, --period-time=# distance between interrupts is # microseconds
-B, --buffer-time=# buffer duration is # microseconds
--period-size=# distance between interrupts is # frames
--buffer-size=# buffer duration is # frames
-A, --avail-min=# min available space for wakeup is # microseconds
-R, --start-delay=# delay for automatic PCM start is # microseconds
(relative to buffer size if <= 0)
-T, --stop-delay=# delay for automatic PCM stop is # microseconds from xrun
-v, --verbose show PCM structure and setup (accumulative)
-V, --vumeter=TYPE enable VU meter (TYPE: mono or stereo)
-I, --separate-channels one file for each channel
--disable-resample disable automatic rate resample
--disable-channels disable automatic channel conversions
--disable-format disable automatic format conversions
--disable-softvol disable software volume control (softvol)
--test-position test ring buffer position
--test-coef=# test coeficient for ring buffer position (default 8)
expression for validation is: coef * (buffer_size / 2)
--test-nowait do not wait for ring buffer - eats whole CPU
--max-file-time=# start another output file when the old file has recorded
for this many seconds
--process-id-file write the process ID here
--use-strftime apply the strftime facility to the output file name
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE
Some of these may not be available on selected hardware
The availabled format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)


arecord -l列出声卡和数字音频设备

card 0: SOUND0 [TI81XX SOUND0], device 0: TVP-PCM tvp5158-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: SOUND0 [TI81XX SOUND0], device 1: AIC3X tlv320aic3x-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0


-D参数用于指定音频设备PCM

以hwx,x开头

根据上面l列出的设备,如果选择tvp5158来录制声音的话那么pcm设备就位hw0,0,如果是tlv320aic3x则pcm设备为hw0,1。

声卡号,设备号

-r指定采样频率:5512/8000/11025/16000/22050/32000/44100/48000/64000/88200/96000/176400/192000

-f指定采样格式上面列出了:cd/cdr/dat

 

录制音频的完整命令例子

arecord -Dhw:0,1 -r8000 -f cd /a/1.wmv

之后在/a目录下可以找到1.wmv文件

 

aplay帮助提示信息

Usage: aplay [OPTION]... [FILE]...

-h, --help help
--version print current version
-l, --list-devices list all soundcards and digital audio devices
-L, --list-pcms list device names
-D, --device=NAME select PCM by name
-q, --quiet quiet mode
-t, --file-type TYPE file type (voc, wav, raw or au)
-c, --channels=# channels
-f, --format=FORMAT sample format (case insensitive)
-r, --rate=# sample rate
-d, --duration=# interrupt after # seconds
-M, --mmap mmap stream
-N, --nonblock nonblocking mode
-F, --period-time=# distance between interrupts is # microseconds
-B, --buffer-time=# buffer duration is # microseconds
--period-size=# distance between interrupts is # frames
--buffer-size=# buffer duration is # frames
-A, --avail-min=# min available space for wakeup is # microseconds
-R, --start-delay=# delay for automatic PCM start is # microseconds
(relative to buffer size if <= 0)
-T, --stop-delay=# delay for automatic PCM stop is # microseconds from xrun
-v, --verbose show PCM structure and setup (accumulative)
-V, --vumeter=TYPE enable VU meter (TYPE: mono or stereo)
-I, --separate-channels one file for each channel
--disable-resample disable automatic rate resample
--disable-channels disable automatic channel conversions
--disable-format disable automatic format conversions
--disable-softvol disable software volume control (softvol)
--test-position test ring buffer position
--test-coef=# test coeficient for ring buffer position (default 8)
expression for validation is: coef * (buffer_size / 2)
--test-nowait do not wait for ring buffer - eats whole CPU
--max-file-time=# start another output file when the old file has recorded
for this many seconds
--process-id-file write the process ID here
--use-strftime apply the strftime facility to the output file name
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE
Some of these may not be available on selected hardware
The availabled format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)


aplay -l 列出声卡和数字音频设备

card 0: SOUND0 [TI81XX SOUND0], device 1: AIC3X tlv320aic3x-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: SOUND1 [TI81XX SOUND1], device 0: hdmi HDMI-DAI-CODEC-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0


-D参数用于指定音频设备PCM

以hwx,x开头

根据上面l列出的设备,如果选择tlv320aic3x来播放声音的话那么pcm设备就位hw0,1,如果是hdmi则pcm设备为hw0,0。

声卡号,设备号

-r指定采样频率:5512/8000/11025/16000/22050/32000/44100/48000/64000/88200/96000/176400/192000

-f指定采样格式上面列出了:cd/cdr/dat

 

完整的播放例子:

aplay -Dhw:0,1 -r8000 -f cd /a/1.wmv


上面的例子必须先录制在播放,如果想要一边播放一边收听可以用下面利用管道的命令

arecord -Dhw:0,1 -r192000 -f cd|aplay -Dhw:0,1 -r192000


 三.交叉编译

1.官网http://www.alsa-project.org下载alsa-lib和alsa-utils

我的版本:alsa-lib-1.0.27.2.tar.bz2 和alsa-utils-1.0.27.2.tar.bz2

2.创建/home/m/3rd/alsa目录,并在目录下创建install目录,接着把压缩包拷到alsa目录下

3.编译alsa-lib步骤

tar -xvf alsa-lib-1.0.27.2.tar.bz2 
cd alsa-lib-1.0.27.2
CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/home/m/3rd/alsa/install/
make
make install
4.编译alsa-utils步骤

tar -xvf alsa-utils-1.0.27.2.tar.bz2
cd alsa-utils-1.0.27.2
CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/home/m/3rd/alsa/install/ --host=arm-linux --with-alsa-inc-prefix=/home/m/3rd/alsa/install/include --with-alsa-prefix=/home/m/3rd/alsa/install/lib --disable-alsamixer --disable-xmlto --disable-nls
make
5.简单说明

--prefix指定了alsa-lib编译后的安装目录,包含库和头文件,编译alsa-utils时候要指明它的库lib和头文件include的目录.

alsamixer是图形化的amixer工具,需要ncurses的支持,在secure CRT中乱码,怕麻烦用--disable-alsamixer禁用了它.

--disable-xmlto和--disable-nls去掉编译都不通过,没去研究为啥.

aplay和arecord是同一个东东改下名字就可以了

真相在此

if (strstr(argv[0], "arecord")) {
stream = SND_PCM_STREAM_CAPTURE;
file_type = FORMAT_WAVE;
command = "arecord";
start_delay = 1;
direction = stdout;
} else if (strstr(argv[0], "aplay")) {
stream = SND_PCM_STREAM_PLAYBACK;
command = "aplay";
direction = stdin;
} else {
error(_("command should be named either arecord or aplay"));
return 1;
}