谷动谷力

 找回密码
 立即注册
查看: 3588|回复: 0
收起左侧

【平头哥Sipeed LicheeRV 86开发板试用】音频播放测试体验aplay...

[复制链接]
发表于 2022-3-5 17:35:20 | 显示全部楼层 |阅读模式
本帖最后由 sunsili 于 2022-3-5 17:57 编辑

【平头哥Sipeed LicheeRV 86开发板试用】音频播放测试体验aplay alsamixer arecord命令


使用scp或sftp传音频文件到开发板, 
推荐此工具
MobaXterm
全带了还有ssh
详情参阅:【分享】MobaXterm 一款远程计算的终极工具箱 ...

MobaXterm

MobaXterm

注传到/tmp目录, /root目录 快满了
如传/root目录,可以会出错误
df命令查看便知:
  1. df
  2. Filesystem           1K-blocks      Used Available Use% Mounted on
  3. /dev/root                99884     82196     10520  89% /
  4. devtmpfs                247644         8    247636   0% /dev
  5. tmpfs                   251840     59576    192264  24% /tmp
  6. /dev/mmcblk0p1            8151       677      7474   8% /mnt/SDCARD
复制代码




查看相关用法aplay
  1. <div>aplay -h
  2. Usage: aplay [OPTION]... [FILE]...

  3. -h, --help              help
  4.     --version           print current version
  5. -l, --list-devices      list all soundcards and digital audio devices
  6. -L, --list-pcms         list device names
  7. -D, --device=NAME       select PCM by name
  8. -q, --quiet             quiet mode
  9. -t, --file-type TYPE    file type (voc, wav, raw or au)
  10. -c, --channels=#        channels
  11. -f, --format=FORMAT     sample format (case insensitive)
  12. -r, --rate=#            sample rate
  13. -d, --duration=#        interrupt after # seconds
  14. -M, --mmap              mmap stream
  15. -N, --nonblock          nonblocking mode
  16. -F, --period-time=#     distance between interrupts is # microseconds
  17. -B, --buffer-time=#     buffer duration is # microseconds
  18.     --period-size=#     distance between interrupts is # frames
  19.     --buffer-size=#     buffer duration is # frames
  20. -A, --avail-min=#       min available space for wakeup is # microseconds
  21. -R, --start-delay=#     delay for automatic PCM start is # microseconds
  22.                         (relative to buffer size if <= 0)
  23. -T, --stop-delay=#      delay for automatic PCM stop is # microseconds from xrun
  24. -v, --verbose           show PCM structure and setup (accumulative)
  25. -V, --vumeter=TYPE      enable VU meter (TYPE: mono or stereo)
  26. -I, --separate-channels one file for each channel
  27. -i, --interactive       allow interactive operation from stdin
  28. -m, --chmap=ch1,ch2,..  Give the channel map to override or follow
  29.     --disable-resample  disable automatic rate resample
  30.     --disable-channels  disable automatic channel conversions
  31.     --disable-format    disable automatic format conversions
  32.     --disable-softvol   disable software volume control (softvol)
  33.     --test-position     test ring buffer position
  34.     --test-coef=#       test coefficient for ring buffer position (default 8)
  35.                         expression for validation is: coef * (buffer_size / 2)
  36.     --test-nowait       do not wait for ring buffer - eats whole CPU
  37.     --max-file-time=#   start another output file when the old file has recorded
  38.                         for this many seconds
  39.     --process-id-file   write the process ID here
  40.     --use-strftime      apply the strftime facility to the output file name
  41.     --dump-hw-params    dump hw_params of the device
  42.     --fatal-errors      treat all errors as fatal
  43. 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
  44. Some of these may not be available on selected hardware
  45. The available format shortcuts are:
  46. -f cd (16 bit little endian, 44100, stereo)
  47. -f cdr (16 bit big endian, 44100, stereo)
  48. -f dat (16 bit little endian, 48000, stereo)
  49. </div>
复制代码

播放设备查看


  1. root@MaixLinux:~# aplay -l
  2. **** List of PLAYBACK Hardware Devices ****
  3. card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC 2030000.codec-0 []
  4.   Subdevices: 1/1
  5.   Subdevice 0: subdevice 0
  6. card 2: sndhdmi [sndhdmi], device 0: 2034000.daudio-audiohdmi-dai 20340a4.hdmiaudio-0 []
  7.   Subdevices: 1/1
  8.   Subdevice 0: subdevice 0
复制代码

播放所有wav
  1. aplay *wav
  2. Playing WAVE 'CS2_AutoplayMusic.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
  3. Playing WAVE 'Call.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Stereo
  4. Playing WAVE 'CallThePolice.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Stereo
  5. Playing WAVE 'CheckOut.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo
  6. Playing WAVE 'Clear.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
  7. Warning: format is changed to U8
  8. Playing WAVE 'Explosion.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
  9. Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
  10. Playing WAVE 'music_4mb.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
  11. Playing WAVE 'music_long.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
复制代码
注:播放wav可以不加参数


播放raw文件

  1. 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用法
  1. arecord -h
  2. Usage: arecord [OPTION]... [FILE]...

  3. -h, --help              help
  4.     --version           print current version
  5. -l, --list-devices      list all soundcards and digital audio devices
  6. -L, --list-pcms         list device names
  7. -D, --device=NAME       select PCM by name
  8. -q, --quiet             quiet mode
  9. -t, --file-type TYPE    file type (voc, wav, raw or au)
  10. -c, --channels=#        channels
  11. -f, --format=FORMAT     sample format (case insensitive)
  12. -r, --rate=#            sample rate
  13. -d, --duration=#        interrupt after # seconds
  14. -M, --mmap              mmap stream
  15. -N, --nonblock          nonblocking mode
  16. -F, --period-time=#     distance between interrupts is # microseconds
  17. -B, --buffer-time=#     buffer duration is # microseconds
  18.     --period-size=#     distance between interrupts is # frames
  19.     --buffer-size=#     buffer duration is # frames
  20. -A, --avail-min=#       min available space for wakeup is # microseconds
  21. -R, --start-delay=#     delay for automatic PCM start is # microseconds
  22.                         (relative to buffer size if <= 0)
  23. -T, --stop-delay=#      delay for automatic PCM stop is # microseconds from xrun
  24. -v, --verbose           show PCM structure and setup (accumulative)
  25. -V, --vumeter=TYPE      enable VU meter (TYPE: mono or stereo)
  26. -I, --separate-channels one file for each channel
  27. -i, --interactive       allow interactive operation from stdin
  28. -m, --chmap=ch1,ch2,..  Give the channel map to override or follow
  29.     --disable-resample  disable automatic rate resample
  30.     --disable-channels  disable automatic channel conversions
  31.     --disable-format    disable automatic format conversions
  32.     --disable-softvol   disable software volume control (softvol)
  33.     --test-position     test ring buffer position
  34.     --test-coef=#       test coefficient for ring buffer position (default 8)
  35.                         expression for validation is: coef * (buffer_size / 2)
  36.     --test-nowait       do not wait for ring buffer - eats whole CPU
  37.     --max-file-time=#   start another output file when the old file has recorded
  38.                         for this many seconds
  39.     --process-id-file   write the process ID here
  40.     --use-strftime      apply the strftime facility to the output file name
  41.     --dump-hw-params    dump hw_params of the device
  42.     --fatal-errors      treat all errors as fatal
复制代码



录音设备查看

  1. root@MaixLinux:~# arecord -l
  2. **** List of CAPTURE Hardware Devices ****
  3. card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC 2030000.codec-0 []
  4.   Subdevices: 1/1
  5.   Subdevice 0: subdevice 0
  6. card 1: snddmic [snddmic], device 0: 2031000.dmic-dmic-hifi dmic-hifi-0 []
  7.   Subdevices: 1/1
  8.   Subdevice 0: subdevice 0
  9. card 2: sndhdmi [sndhdmi], device 0: 2034000.daudio-audiohdmi-dai 20340a4.hdmiaudio-0 []
  10.   Subdevices: 1/1
  11.   Subdevice 0: subdevice 0
复制代码

录音命令

  1.     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 保存录音文件名



播放录音
  1. aplay -D hw:0,0 test_record.wav
复制代码


用alsamixer 进行音量调整

输入alsamixer命令
  1. alsamixer
复制代码

alsamixer

alsamixer



总结

本篇测试了Sipeed LicheeRV 86 Panel开发板使用aplay alsamixer arecord命令音频播放测试, 解码能力还是加强, 播放时CPU100%

aplay htop

aplay htop


音质还要加强, 我还换喇叭了


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-4-19 10:00 , Processed in 0.096844 second(s), 37 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表