您尚未登录。

楼主 # 2021-08-20 20:33:40

xfdr0805
会员
注册时间: 2020-07-23
已发帖子: 311
积分: 354

交叉编译音频界的瑞士军刀SOX可以播放音乐(mp3,flac,wav...)并产生各种测试音频信号

1.从此处下载sox官网http://sox.sourceforge.net 解压后新建一个autoconfig.sh脚本
这里使用了绝对路径,使用相对路径在最后链接时找不到文件,所以直接使用了绝对路径,里边的一些插件如果不需要可以去掉,我也一起打包传上来,另外这手动编译依赖可真烦那,只能缺哪个下载哪个再编译哪个最后才能给链接出来,跟buildroot里3S钟把sox勾选上完事编译完事相比,手动编译估计得3小时 ^*_*^,简直弱爆了,附件在最后,是修改好的源文件,稍做修改即可编译。

#!/bin/sh
./configure
CC=”arm-linux-gnueabihf-gcc”
LDFLAGS=”-L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/alsa/ -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/flac-1.3.3/src/libFLAC/.libs -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/lame-3.100/libmp3lame/.libs/ -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/twolame-0.4.0/libtwolame/.libs/ -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/libmad-0.15.1b/.libs/ -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/libid3tag-0.15.1b/.libs/ -L/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/zlib-1.2.11”
CFLAGS=”-I/home/xfdr/v3s_licheepi_zero/buildroot-2021.02/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/ -I/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/lame-3.100/include/ -I/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/flac-1.3.3/src/libFLAC/ -I/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/twolame-0.4.0/libtwolame/ -I/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/libmad-0.15.1b/ -I/home/xfdr/v3s_licheepi_zero/sox-14.4.2-sonavox/libid3tag-0.15.1b/“
–prefix /opt/sox.14.4.2
–host=arm-linux-gnueabihf
–target=arm-linux
–with-alsa
–with-flac
–with-mp3
–with-id3tag
–with-lame
–with-wavpack
#–with-twolame \

2.编译完成后执行make install 即可,安装目录就是上边指定的,拷贝到开发板或者NFS目录下

3.先来播放音乐试一下

# ./sox.14.4.2/bin/play -t mp3 ./群星-雨花石.mp3
./sox.14.4.2/bin/play WARN alsa: can’t encode 0-bit Unknown or not applicable

./群星-雨花石.mp3:

File Size: 13.7M Bit Rate: 321k
Encoding: MPEG audio Info: 163 key(Don’t modify):cEgtqHxwpdRKcBCRPBlPkg2DgcBlNoDaE7DLI/2UHqynoBve87Svw+quIkOr72Ov7q2menCG1hUs953Iws8wjHxQUjhQGB3sa2Sa9AVOc0ek4+GcHOxN9VcDh3GNItlfDRG7Pi/y+oz0U3xrKMvDiHZErPJlv6SHCl/k5qddt6BXsgTw3fn/9fNu/LLy/lawUWghlFz+aUkza7omDosFsjHYbZYrBjDqcCegSdhUOA43QD89da8FaXkqPqcMQVYqEBm7uirR2NrhGOOGt29H8sgWqCZ1icsjX7XcnX0035IQQ5Fj3dVW49U4iJMDLJtbM9DDheK/KwCziC1y9ISodum8kf9PC7+b+JLNr/mhg5DifEjdqngnEHAzqRUNufhtjc530m+aglaPBRphTfryHMYPKTWq311dQFnn9Ru1rnrpjBwyc9avaOrd10VsncqCPRHdRET/f7ygAMyztzSPzQ==
Channels: 2 @ 16-bit Track: 4
Samplerate: 44100Hz Album: 女人如歌 柔情魅声
Replaygain: off Artist: 群星
Duration: 00:05:40.79 Title: 雨花石

In:1.23% 00:00:04.18 [00:05:36.61] Out:184k [ =|== ] Clip:0
Aborted.
# ./sox.14.4.2/bin/play -t flac ./wodeloulan.flac
./sox.14.4.2/bin/play WARN alsa: can’t encode 0-bit Unknown or not applicable

./wodeloulan.flac:

File Size: 39.0M Bit Rate: 952k
Encoding: FLAC
Channels: 2 @ 16-bit
Samplerate: 44100Hz Album: 倔强
Replaygain: off Artist: 云朵
Duration: 00:05:27.59 Title: 我的楼兰

In:0.48% 00:00:01.58 [00:05:26.01] Out:69.6k [ ===|==- ] Clip:0
Aborted.

4.本地音乐播放没问题,也可以播放网络音频,实际就是通过wget获取的

# ./play -t flac http://192.168.6.123:8080/wodeloulan.flac
./play WARN alsa: can’t encode 0-bit Unknown or not applicable

http://192.168.6.123:8080/wodeloulan.flac:

File Size: 0 Bit Rate: 0
Encoding: FLAC
Channels: 2 @ 16-bit
Samplerate: 44100Hz Album: 倔强
Replaygain: off Artist: 云朵
Duration: 00:05:27.59 Title: 我的楼兰

In:0.57% 00:00:01.86 [00:05:25.73] Out:81.9k [ ==|==- ] Clip:0
Aborted.

5.下边开始使用sox产生一些测试信号试试,产生1Khz 44.1KHz 0dB 的sin pink white

play -V -r 48000 -b 16 -c 2 -n synth sin 1000 vol 0db  #产生正弦波
play -V -r 48000 -b 16 -c 2 -n synth pink 1000 vol 0db #产生粉红噪音
play -V -r 48000 -b 16 -c 2 -n synth white 1000 vol 0db #产生白噪音
# ./play -V -r 48000 -b 16 -c 2 -n synth pink 1000 vol 0db
./play WARN alsa: can’t encode 0-bit Unknown or not applicable
./play: SoX v14.4.2

Input File : ‘’ (null)
Channels : 2
Sample Rate : 48000
Precision : 16-bit
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no

./play INFO formats: can't set sample rate 48000; using 44100

Output File : ‘default’ (alsa)
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Sample Encoding: 16-bit Signed Integer PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no

./play INFO vol: has no effect in this configuration
./play INFO sox: effects chain: input 48000Hz 2 channels
./play INFO sox: effects chain: synth 48000Hz 2 channels
./play INFO sox: effects chain: rate 44100Hz 2 channels
./play INFO sox: effects chain: dither 44100Hz 2 channels
./play INFO sox: effects chain: output 44100Hz 2 channels
In:0.00% 00:00:04.78 [00:00:00.00] Out:203k [ | ] Hd:3.4 Clip:0
Aborted.

6.从 20Hz 到 20kHz 的频率扫描,持续时间为 30 秒 音量0 重复10次

play -V -r 44100 -b -c 2 -n synth 30 sin 20+20000 vol 0db repeat 10

7.20-10kHz 和 1kHz-20kHz 双频扫描

play -V -r 44100 -n synth 30 sin 20+10000 sin 1000+20000 remix 1,2 channels 2

8.sox功能还有很多,不过这几个功能目前已经满足我的需要了,其它高级玩法就留给大家了

sox-14.4.2-sonavox.7z

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn