SOX Conversions, Raw Files, Splitting And Merging Channels

1 篇文章 0 订阅
1 篇文章 0 订阅

Today the command line audio utility sox gave me some head aches while I was working on some sample files for a listening test I prepare for my current research. I actually just needed to convert a stereo 44.1kHz floating point WAV file to 48kHz, split it into single mono files (one for each channel), convert the mono files to raw PCM, process some filter on the raw files, convert them back to mono WAVs, merge the mono files back to stereo again and convert back to 44.1kHz. To accomplish this, I used these commands, which were neither well documented, nor correctly referred to by most of the blogs I've worked through today.

The following command simply converts the samplerate to 48kHz (nothing special):

sox infile.wav -r 48k outfile.wav

These commands split the stereo file into two mono files (left and right channel):

sox infile.wav outfile.l.wav remix 1
sox infile.wav outfile.r.wav remix 2

The following commands create a mono mix-down of a stereo file

sox infile.wav outfile.wav remix 1,2
sox infile.wav outfile.wav remix 1-2
The following command converts a wav file to a raw 16-bit signed integer mono file with 48kHz:

sox infile.wav -b 16 -s -c 1 -r 48k -t raw outfile.raw
The following command converts a raw file back to WAV (option -t raw is mandatory!):

sox -b 16 -s -c 1 -r 48k -t raw infile.wav outfile.wav
The following command merges the two mono files into one stereo WAV file (order: left, right):

sox -M input.l.wav input.r.wav output.wav
This command converts the 48kHz back to 44.1kHz:

sox input.wav -r 44100 output.wav
Another nice command, not too intrusively documented is the following:
sox audiofile.wav -n stat

which allows scripts to read audio signal attributes like overall gain, mean values etc. from audio files and use them afterward e.g. for normalization, dc-offset compensation, etc.

Another command for acquiring signal information is soxi:

soxi audiofile.wav
The main problem for me today was the flag '-t raw', which is not stated as mandatory in the sox manpage for raw file, but it actually is! Anyhow, the remaining part is pretty straight forward.

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、下4载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、下4载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、 4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值