TX2音頻測試記錄
Tx2官方的開發套件上沒有音頻的測試接口,使用realtimes的9001進行測試,記錄一下.
驅動realtimes都已經做好了,所以我們直接使用就可以了.
默認音量比較小,需要使用以下命令進行設置:
$ amixer cset numid=581,iface=MIXER,name='x Headphone Playback Volume'
118
對於連接帶有播放功能的 HDMI 顯示器等系統會自動生成播放聲音通道。對於音量
的調整需要添加參數,默認爲顯示器聲卡,參數爲 0,載板自帶聲卡參數爲 1。
命令調整如下:
$ amixer cset numid=581,iface=MIXER,name='x Headphone Playback Volume'
118 –c 1
下面來看一下amixer命令使用方法:
➜ ~ amixer -h
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
-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
後面添加 -c選項是選擇一下是哪個聲卡,hdmi的聲卡會被顯示爲第0個
amixer controls顯示接口函數
➜ ~ amixer controls
numid=21,iface=CARD,name='Front Headphone Jack'
numid=19,iface=CARD,name='Front Mic Jack'
numid=20,iface=CARD,name='Line Out Jack'
numid=18,iface=CARD,name='Rear Mic Jack'
numid=22,iface=CARD,name='Speaker Phantom Jack'
numid=17,iface=MIXER,name='Master Playback Switch'
numid=16,iface=MIXER,name='Master Playback Volume'
numid=1,iface=MIXER,name='Headphone+LO Playback Volume'
numid=3,iface=MIXER,name='Headphone Playback Switch'
numid=25,iface=MIXER,name='PCM Playback Volume'
numid=15,iface=MIXER,name='Front Mic Boost Volume'
numid=10,iface=MIXER,name='Front Mic Playback Switch'
numid=9,iface=MIXER,name='Front Mic Playback Volume'
numid=2,iface=MIXER,name='Line Out Playback Switch'
numid=13,iface=MIXER,name='Capture Switch'
numid=12,iface=MIXER,name='Capture Volume'
numid=6,iface=MIXER,name='Loopback Mixing'
numid=11,iface=MIXER,name='Auto-Mute Mode'
numid=14,iface=MIXER,name='Rear Mic Boost Volume'
numid=8,iface=MIXER,name='Rear Mic Playback Switch'
numid=7,iface=MIXER,name='Rear Mic Playback Volume'
numid=5,iface=MIXER,name='Speaker Playback Switch'
numid=4,iface=MIXER,name='Speaker Playback Volume'
numid=24,iface=PCM,name='Capture Channel Map'
numid=23,iface=PCM,name='Playback Channel Map'
amixer contents
➜ ~ amixer contents
numid=21,iface=CARD,name='Front Headphone Jack'
; type=BOOLEAN,access=r-------,values=1
: values=off
numid=19,iface=CARD,name='Front Mic Jack'
; type=BOOLEAN,access=r-------,values=1
: values=off
numid=20,iface=CARD,name='Line Out Jack'
; type=BOOLEAN,access=r-------,values=1
: values=off
numid=18,iface=CARD,name='Rear Mic Jack'
; type=BOOLEAN,access=r-------,values=1
: values=off
numid=22,iface=CARD,name='Speaker Phantom Jack'
; type=BOOLEAN,access=r-------,values=1
: values=on
numid=17,iface=MIXER,name='Master Playback Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=16,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=87,step=0
: values=0
| dBscale-min=-65.25dB,step=0.75dB,mute=0
numid=1,iface=MIXER,name='Headphone+LO Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=87,step=0
: values=0,0
| dBscale-min=-65.25dB,step=0.75dB,mute=0
numid=3,iface=MIXER,name='Headphone Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=off,off
numid=25,iface=MIXER,name='PCM Playback Volume'
; type=INTEGER,access=rw---RW-,values=2,min=0,max=255,step=0
: values=0,0
| dBscale-min=-51.00dB,step=0.20dB,mute=0
numid=15,iface=MIXER,name='Front Mic Boost Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
: values=0,0
| dBscale-min=0.00dB,step=10.00dB,mute=0
numid=10,iface=MIXER,name='Front Mic Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=off,off
numid=9,iface=MIXER,name='Front Mic Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
: values=0,0
| dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=2,iface=MIXER,name='Line Out Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=13,iface=MIXER,name='Capture Switch'
; type=BOOLEAN,access=rw------,values=2
: values=on,on
numid=12,iface=MIXER,name='Capture Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0
: values=0,0
| dBscale-min=-17.25dB,step=0.75dB,mute=0
numid=6,iface=MIXER,name='Loopback Mixing'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'Disabled'
; Item #1 'Enabled'
: values=0
numid=11,iface=MIXER,name='Auto-Mute Mode'
; type=ENUMERATED,access=rw------,values=1,items=3
; Item #0 'Disabled'
; Item #1 'Speaker Only'
; Item #2 'Line Out+Speaker'
: values=2
numid=14,iface=MIXER,name='Rear Mic Boost Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
: values=0,0
| dBscale-min=0.00dB,step=10.00dB,mute=0
numid=8,iface=MIXER,name='Rear Mic Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=off,off
numid=7,iface=MIXER,name='Rear Mic Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
: values=0,0
| dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=5,iface=MIXER,name='Speaker Playback Switch'
; type=BOOLEAN,access=rw------,values=2
: values=off,off
numid=4,iface=MIXER,name='Speaker Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=87,step=0
: values=0,0
| dBscale-min=-65.25dB,step=0.75dB,mute=0
numid=24,iface=PCM,name='Capture Channel Map'
; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
numid=23,iface=PCM,name='Playback Channel Map'
; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
amixer cget + 接口函數
➜ ~ amixer cget numid=23,iface=PCM,name='Playback Channel Map'
numid=23,iface=PCM,name='Playback Channel Map'
; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
amixer cset + 接口函數 + 設置參數參數(0,1,off,on)
cset又是什麼呢? c應該 是contents那麼cset就是設置 contents中的值.都有哪些可設置使用 amixer contents進行查看.
保存修改的數據:alsactl store
修改的參數在重新啓動後不會被保存,需要使用alsactl store進行保存一下.
測試
使用以下命令進行測試,使用arecord進行錄音 ,使用aplay進行播放.下面的命令是邊錄邊播.
arecord -D hw:1,0 -r 48000 -f S16_LE -c 2 | aplay -D hw:1,0 -r 48000
-D 表示設備
-r 表示採樣率
-f format格式
-c channels表示通道數
先來看一下使用說明
arecord -h
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
-i, --interactive allow interactive operation from stdin
-m, --chmap=ch1,ch2,.. Give the channel map to override or follow
--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 coefficient 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
--dump-hw-params dump hw_params of the device
--fatal-errors treat all errors as fatal
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 U18_3BE G723_24 G723_24_1B G723_40 G723_40_1B DSD_U8 DSD_U16_LE DSD_U32_LE DSD_U16_BE DSD_U32_BE
Some of these may not be available on selected hardware
The available 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 -h
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
-i, --interactive allow interactive operation from stdin
-m, --chmap=ch1,ch2,… Give the channel map to override or follow
–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 coefficient 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
–dump-hw-params dump hw_params of the device
–fatal-errors treat all errors as fatal
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 U18_3BE G723_24 G723_24_1B G723_40 G723_40_1B DSD_U8 DSD_U16_LE DSD_U32_LE DSD_U16_BE DSD_U32_BE
Some of these may not be available on selected hardware
The available 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)