From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3561 216.34.176.0/20 X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A4FD01F404 for ; Sat, 10 Feb 2018 20:08:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1ekbRz-0006bT-Li; Sat, 10 Feb 2018 20:08:43 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ekbRy-0006bN-Ha for sox-users@lists.sourceforge.net; Sat, 10 Feb 2018 20:08:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wOen1f180xiWPey/FtYG3WbjPZU67PQIur4SxkTsgjI=; b=GfyUpHP7TmUvbsGxjKrS2N0gFP MecCHl5IolKJ/aB5qlDZzuRYg7vF0amxmxaH/vCimH3LFaB/+zMQ8A/9QQyLYwnifsLCFyYoviZNb SpG39ENMq+eSbJBLEItI9qSePwwrMq1b2ynGBU1JEqiMNEnDifPnBWcatMMkt+g4RYJQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wOen1f180xiWPey/FtYG3WbjPZU67PQIur4SxkTsgjI=; b=jXUMUhIz6pELDGH8agxvhssz0r ZiJqE5hZO8YVng0O9ujYiYbuec7vzk8ra1c/ThsEhaoshKlmvofTtNCOq2LGJukDJide7dFOTSYiu Wxb+al0Uec970c+KY/erGcc8HvbF21xhegmUjGmctOpbVsARqFQSjHWydSsDanIdDUtw=; Received: from mx.stare.cz ([79.98.77.229]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) id 1ekbRw-0006js-PO for sox-users@lists.sourceforge.net; Sat, 10 Feb 2018 20:08:42 +0000 Received: from www.stare.cz (localhost [127.0.0.1]) by www.stare.cz (OpenSMTPD) with ESMTP id 35a3d576 for ; Sat, 10 Feb 2018 21:08:33 +0100 (CET) Date: Sat, 10 Feb 2018 21:08:33 +0100 From: Jan Stary To: sox-users@lists.sourceforge.net Message-ID: <20180210200833.GA40965@www.stare.cz> Mail-Followup-To: sox-users@lists.sourceforge.net References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-Headers-End: 1ekbRw-0006js-PO Subject: Re: Sox multiple output file trim X-BeenThere: sox-users@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-users@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: sox-users-bounces@lists.sourceforge.net On Dec 06 01:17:16, sichengwang.gatech@gmail.com wrote: > 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. Why do you need/want to concatenate them and then cut it again? > 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 Only if all the lengths are 30 seconds. > Here is my code: > $ sox 440a0101.wav 440a0102.wav 440a0103.wav tmp.wav > $ soxi 440a010[1-3].wav -D That's not an actual sox line; use script(1). > 5.538938 > 5.773500 > 6.409750 > $ soxi 440a010[1-3].wav -DT > 17.722188 > $ soxi tmp.wav -D > 17.722188 > $ sox tmp.wav out%2n.wav trim 0 5.538938 : newfile : trim 0 5.773500 > $ soxi out0[1-2].wav -D > 5.538938 > 5.773500 > $ cmp 440a0101.wav out01.wav > $ cmp 440a0102.wav out02.wav > 440a0102.wav out02.wav differ: byte 45, line 1 That would be right after the WAV header, which I believe is 44 bytes in usual cases. So they differ in the first sample already. > Upon closer inspection, I found that out02.wav is shifted by something like > 1000 samples from 440a0102.wav. How exactly did you find out? > 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. Yes, it's probably the buffering. How exactly does the behavior change if you change --buffer and/or --input-buffer? > I don't think it is the way I'm specifying the time, is it. 5.538938 is 5.538938, nothing wrong with that. > 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. How many samples does out02.wav contain then? > My sox is sox: SoX v14.3.2 The latest SoX is 14.4.2, released three years ago? Please try also with that. But I think you are right and it's the buffering, which probably has not changed. > 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. If the lengths are different, you need to specify all of them anyway: $ sox tmp.wav out%2n.wav trim 0 5.538938 : newfile : trim 0 5.773500 vs $ sox tmp.wav out1.wav trim 0.000000 5.538938 $ sox tmp.wav out2.wav trim 5.538938 5.773500 Jan ------------------------------------------------------------------------------ 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 Sox-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-users