|
本帖最后由 sunsili 于 2022-3-5 17:57 编辑
【平头哥Sipeed LicheeRV 86开发板试用】音频播放测试体验aplay alsamixer arecord命令
使用scp或sftp传音频文件到开发板,
推荐此工具
MobaXterm
全带了还有ssh
详情参阅:【分享】MobaXterm 一款远程计算的终极工具箱 ...
注传到/tmp目录, /root目录 快满了
如传/root目录,可以会出错误
df命令查看便知:
- df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/root 99884 82196 10520 89% /
- devtmpfs 247644 8 247636 0% /dev
- tmpfs 251840 59576 192264 24% /tmp
- /dev/mmcblk0p1 8151 677 7474 8% /mnt/SDCARD
复制代码
查看相关用法aplay
- <div>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)
- </div>
复制代码
播放设备查看
- root@MaixLinux:~# aplay -l
- **** List of PLAYBACK Hardware Devices ****
- card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC 2030000.codec-0 []
- Subdevices: 1/1
- Subdevice 0: subdevice 0
- card 2: sndhdmi [sndhdmi], device 0: 2034000.daudio-audiohdmi-dai 20340a4.hdmiaudio-0 []
- Subdevices: 1/1
- Subdevice 0: subdevice 0
复制代码
播放所有wav
- aplay *wav
- Playing WAVE 'CS2_AutoplayMusic.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
- Playing WAVE 'Call.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Stereo
- Playing WAVE 'CallThePolice.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Stereo
- Playing WAVE 'CheckOut.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo
- Playing WAVE 'Clear.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
- Warning: format is changed to U8
- Playing WAVE 'Explosion.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
- Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
- Playing WAVE 'music_4mb.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
- Playing WAVE 'music_long.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
复制代码 注:播放wav可以不加参数
播放raw文件
- aplay -t raw -c 1 -f S16_LE -r 8000 *.raw
复制代码 注:
-t: type raw表示是PCM
-c: channel 1
-f S16_LE: Signed 16bit-width Little-Endian
-r: sample rate 8000
PCM是最raw的音频数据,没有任何头信息。WAV文件就是PCM+头信息,头信息就是上述的声道数,sample rate这些。所以WAV文件可以直接播放,而PCM需要手动指定这些信息之后才能播放。
*****注意:aplay是不能解码mp3, 所以播放不了mp3, 播出来是杂声
录放音测试:
查看arecord用法
- 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
复制代码
录音设备查看
- root@MaixLinux:~# arecord -l
- **** List of CAPTURE Hardware Devices ****
- card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC 2030000.codec-0 []
- Subdevices: 1/1
- Subdevice 0: subdevice 0
- card 1: snddmic [snddmic], device 0: 2031000.dmic-dmic-hifi dmic-hifi-0 []
- Subdevices: 1/1
- Subdevice 0: subdevice 0
- card 2: sndhdmi [sndhdmi], device 0: 2034000.daudio-audiohdmi-dai 20340a4.hdmiaudio-0 []
- Subdevices: 1/1
- Subdevice 0: subdevice 0
复制代码
录音命令
- arecord -D hw:1,0 -f S16_LE -t wav -d 10 test_record.wav
复制代码 注:
-D hw:1,0 录音设备
-f S16_LE 16位数据格式
-t wav 保存为wav 格式
-d 10 录音时长10s
test_record.wav 保存录音文件名
播放录音:
- aplay -D hw:0,0 test_record.wav
复制代码
用alsamixer 进行音量调整
输入alsamixer命令
总结
本篇测试了Sipeed LicheeRV 86 Panel开发板使用aplay alsamixer arecord命令音频播放测试, 解码能力还是加强, 播放时CPU100%
音质还要加强, 我还换喇叭了
|
+10
|