Sox multiple output file trim
Sicheng Wang <[email protected]>
| Newsgroups | gmane.comp.audio.sox |
|---|---|
| Message-ID | <CAN+FrMNW85=oe7XS4G97_k_zG9kg=oRaKkedzV5JG1tf2dcx2A@mail.gmail.com> |
Hi all,
I've been playing around with some amazing effects in Sox. Right now I
concatenated many short files sequentially to create a long audio. (I'm
going to do something with this long audio, but due to the issue I'm going
to describe, I leave the long audio untouched for now). Afterwards I wish
to split the long audio into smaller segments with the same duration my
short files (like disassembling the long audio into its original short
pieces) . I expect to get the same short audios back.
It seems the following line of code in the manual does the thing closest
to what I wish:
sox song.wav ringtone%1n.wav trim 0 30 : newfile : trim 0 30
Here is my code:
swang423@cw4:~/tmp>$ sox 440a0101.wav 440a0102.wav 440a0103.wav tmp.wav
#concat
swang423@cw4:~/tmp>$ soxi 440a010[1-3].wav -D
#Get wav dur
5.538938
5.773500
6.409750
swang423@cw4:~/tmp>$ soxi 440a010[1-3].wav -DT
#Get Total dur
17.722188
swang423@cw4:~/tmp>$ soxi tmp.wav -D
#Long dur; match is good
17.722188
swang423@cw4:~/tmp>$ sox tmp.wav out%2n.wav trim 0 5.538938 : newfile :
trim 0 5.773500 #Trim to get the first 2 file
swang423@cw4:~/tmp>$ soxi out0[1-2].wav -D
#Check dur match; match is
good
5.538938
5.773500
swang423@cw4:~/tmp>$ cmp 440a0101.wav out01.wav
#The first files areidentical
swang423@cw4:~/tmp>$ cmp 440a0102.wav out02.wav
#The second files are not
440a0102.wav out02.wav differ: byte 45, line 1
Upon closer inspection, I found that out02.wav is shifted by something like
1000 samples from 440a0102.wav.
The last file could not be trimmed successfully as well, since the output
will be shorter than the original. I suspect the buffer has something to do
with it. But I could always use the "reverse-trim-reverse" trick for the
last file.
I don't think it is the way I'm specifying the time, is it. I also tried to
specify it with sample count:
swang423@cw4:~/tmp>$ sox tmp.wav out%2n.wav trim 0s 88623s : newfile : trim
0s 92376s
but the results are the same.
My sox is sox: SoX v14.3.2 running on
swang423@cw4:~/tmp>$ uname -a
Linux cw4 3.8.0-44-generic #66~precise1-Ubuntu SMP Tue Jul 15 04:01:04 UTC
2014 x86_64 x86_64 x86_64 GNU/Linux
BTW I ended up doing
sox tmp.wav out02.wav trim 5.538938 5.773500
which works out fine. But I need to do this a dozen of times. I still think
the "multiple output" seems more elegant.
Thanks.
Sicheng
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sox-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sox-users