TX2音频测试记录

TX2音频测试记录

  • amixer contents
  • amixer cget + 接口函数
  • amixer cset + 接口函数 + 设置参数参数(0,1,off,on)
  • 保存修改的数据:alsactl store
  • 测试

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)








你可能感兴趣的:(TX2)