-1

I use the following code to trim, pipe and concatenate my audio files.

sox "|sox audio.wav -p trim 0.000 =15.000" "|sox audio.wav -p trim 15.000" concatenated.wav

One would expect that concatenated.wav will sound identical compared to a.wav.
However, when both files are played simultaneously together, there is a distinct audio shift on concatenated.wav.

Normally this error is acceptable as it is in the milliseconds range. However, as the number of pipe increases (say more than 100), the amount of audio shift increases substantially.

What is the correct method to trim, pipe and concatenate audio files using SoX to prevent this error?

Edit 1: Samples was used instead of milliseconds. Still met the same problem.
The following code was used:

sox "|sox audio.wav -p trim 0s =661500s" "|sox audio.wav -p trim 661500s" concatenated.wav

Wave file sample rate is 44100hz. Sample size is 16 bit.
SoX 14-4-2 was used.

Schinizer
  • 306
  • 3
  • 9

1 Answers1

0

The problem is that sox may lose a few samples at the cut point of the trim command.

I had a similar problem and solved it by cutting not by milliseconds, but by samples, which of course depend on the sample rate.

If your cutpoints are multiples of the used sample rate, you will no longer lose samples and the combined parts will have the exact same length as the original.

576i
  • 7,579
  • 12
  • 55
  • 92