sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
From: Sicheng Wang <sichengwang.gatech@gmail.com>
To: sox-users@lists.sourceforge.net
Subject: Sox multiple output file trim
Date: Wed, 6 Dec 2017 01:17:16 -0500	[thread overview]
Message-ID: <CAN+FrMNW85=oe7XS4G97_k_zG9kg=oRaKkedzV5JG1tf2dcx2A@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2607 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 3854 bytes --]

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

             reply	other threads:[~2017-12-06  6:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06  6:17 Sicheng Wang [this message]
2018-02-10 20:08 ` Sox multiple output file trim Jan Stary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.sourceforge.net/lists/listinfo/sox-users

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN+FrMNW85=oe7XS4G97_k_zG9kg=oRaKkedzV5JG1tf2dcx2A@mail.gmail.com' \
    --to=sox-users@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).