1

I want to keep several sections of an audio file, merged together, but without any discontinuities ("clicks") at the join points. There's a SoX command that does this (https://superuser.com/a/677351), but it does not do any crossfade, so there will be discontinuities. Is there a way to achieve that, using a command-line utility or a library? (Besides writing my own code — I'd certainly do that if I have to)

1

Turns out, this is entirely possible to do with SoX, even with just a single SoX invocation, using trim and splice effects. But the numeric arguments are not straightforward to write. All trim regions except the last must include additional amount of time at the end that will be used for crossfading, and arguments to splice must also specify proper lengths of 1st region including that extra time, 1st + 2nd after first splicing, 1st + 2nd + 3rd, etc.

I wrote a script that does this (in Scala language), and I will release it, sooner or later.

There's a drawback in Sox, seems like trim effect does not work with floating point format, so at the end audio data gets converted to (at most) 24-bit integer format, this may be acceptable or not depending on your use case.

3
  • I know it's three years later, but would have loved to see a sox example (I don't know Scala) even if it doesn't exactly show the timing. – kr37 Jul 3 '18 at 13:06
  • @kr37 I have not used it for a long while but maybe I'll find it and update the answer with more details when I have some free time. Feel free to ping me again on weekend if I don't do this yet. – Display Name Jul 3 '18 at 14:12
  • Thank you, in my case the timing is not very particular. It seems that a simple sox test.wav out.wav trim 50:00 =51:00 52:00 =53:00 54:00 =55:00 splice -q works just fine. – kr37 Jul 3 '18 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.