SoX pipe operations and data loss

1

When piping operations using SoX, I've noticed that files get shorter than they should:

Works fine:

sox -n -r 44100 silence.wav trim 0 1
sox --combine sequence silence.wav combined.wav
soxi -D combined.wav
> 1.000000

The resulting file gets shorter:

sox -n -r 44100 silence.wav trim 0 1
sox --combine sequence "|sox silence.wav -p" combined.wav
soxi -D combined.wav
> 0.998549 seconds

Tested with SoX version 14.4.1 on Windows 7 64 Family Edition. (On Windows, create a copy of sox.exe named soxi.exe for soxi to work.)

I'll spare you the rest of the details but there's basically a loss of 0.001451 sec for EACH pipe operation. (A little less at higher sampling rates.) For anything where accuracy is important, those milliseconds add up and do become significant, creating lags between where you expect the audio to be and where it really is.

Before I submit a bug report to the SoX team, I'd like to figure out if it really is a bug or isn't rather command-line related. Would anyone be kind enough to run both sets of commands on their system and post the results?

Thanks in advance -

Fabien Snauwaert

Posted 2014-04-02T03:10:24.147

Reputation: 342

1I do not see this problem with sox v14.4.1 running on a recent GNU/Linux system, i.e. both examples yield 1.000000. – Thor – 2014-04-02T07:54:14.803

Answers

0

On a windows 7 64 bits:

sox "|sox source -p trim 0 10" "|sox source -p trim 0 10" destination

Indeed gives me the same kind of buggy results (19.997s).

BUT

sox -t sox "|sox source -p trim 0 10" -t sox "|sox source -p trim 0 10" destination

Gives me the right results (20.0s).

From what I have read on some websites, you should specify the type of the pipe you use. And since "-p" is equivalent to "-t sox -", you ought to add "-t sox" in the "pipe using" sox call.

turtur_ninja

Posted 2014-04-02T03:10:24.147

Reputation: 1