From: Eric Wong <normalperson@yhbt.net>
To: sox-users@lists.sourceforge.net
Subject: Re: trim slow with multiple files
Date: Mon, 25 Mar 2024 09:55:19 +0000 [thread overview]
Message-ID: <20240325095519.M332919@dcvr> (raw)
In-Reply-To: <58F57788-B837-4336-B998-EC48649026F8@klaus-kauker.de>
Klaus Kauker <mail@klaus-kauker.de> wrote:
> Hey there
>
> if I play one single file with e.g. 30 seconds in it plays pretty much instantly. e.g.: play file1.mp3 trim 30
Right, src/sox.c has optimize_trim() when trim is the
first effect but AFAIK it only affects single inputs
> If I pass more than one file sox somehow takes much longer to seek to the desired position: play file1.mp3 file2.mp3 trim 30
Yeah, the optimize_trim() function only triggers with single inputs.
Maybe Jan has a faster computer and didn't notice "trim 30"
taking longer to start than no trim at all. Using a larger
value (e.g. "trim 300" on longer audio files) will make a more
noticeable delay for faster computers.
> I think modifying the command to: play file1.mp3 trim 30 ; play file2.mp3 works fine in most cases but it introduces an audible gap between the files.
Right, that will restart your audio device, and AFAIK sox doesn't
make use of the metadata required for gapless mp3 playback.
(FLAC and most other formats don't need special code for gapless)
> Is there a solution for gapless playback and fast trimming?
You can have two sox invocations write to the same pipe via
subshell:
FMT='-t s32 -r 44100 -c2' # any format will work, but it has to be consistent
(sox file1.mp3 $FMT - trim 30 && sox file2.mp3 $FMT -) | play $FMT -
I expect the gaps will still be there with mp3 files, though.
_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users
prev parent reply other threads:[~2024-03-25 10:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 20:58 trim slow with multiple files Klaus Kauker
2024-03-09 8:17 ` Jan Stary
2024-03-25 9:55 ` Eric Wong [this message]
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=20240325095519.M332919@dcvr \
--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).