Menu

#258 Sox produces non-deterministic / non-reproducible output when resampling!

closed-invalid
nobody
None
7
2018-04-28
2015-02-28
florian.e
No

Using sox 14.4.1 on Ubuntu 14.04 LTS (installed via apt), when I run:
sox example.wav -r 16000 out01.wav rate
sox example.wav -r 16000 out02.wav rate
diff out01.wav out02.wav
=> Binary files out01.wav and out02.wav differ

Input has 44100 or 22050 Hz. Tried with two different files, same result. Independent of rate effect or using downsample or upsample effects.

I believe the output should be the same, when you run the programm twice! This is important for many kinds of applications relying on sox for reproducible output.

Has anybody got a clue why this might be happening? Some uninitialized states in cut-off filters, or some more general memory issues?

Discussion

  • florian.e

    florian.e - 2015-02-28

    EDIT: I've just found out that it also occurs for other conversions, which do not include resampling:

    Input: 44100 Hz, 2 channels, 16 bit signed int

    sox example2ch.wav -c 1 -s -2 out01.wav
    sox example2ch.wav -c 1 -s -2 out02.wav
    diff out01.wav out02.wav
    => Outputs differ

    If the input in the above sample is 1 channel already, the two output files produced are identical, as it appears that sox detects that no conversion is neccessary, and then just copies?

     
  • florian.e

    florian.e - 2015-02-28

    Another update: I've found the issue to be related to the automatic dithering which is added. It appears that the random seed of the RNG used to produce the dither white noise is not initialized with a fixed value. In principle this is not wrong, but it would be nice to control this behaviour to force sox to produce the exact same output when invoked twice on the same file (some other option besides -D to completely disable the dither).

     
  • robs

    robs - 2015-02-28

    There is already an option for this: -R

     
  • florian.e

    florian.e - 2015-03-01

    Ah, thanks, that works! Had overlooked this one in the documentation of the "dither" effect. Still a bit weired though that this is not the default.

     
  • Mans Rullgard

    Mans Rullgard - 2018-04-28
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     Using sox 14.4.1 on Ubuntu 14.04 LTS (installed via apt), when I run:
     sox example.wav -r 16000 out01.wav rate
     sox example.wav -r 16000 out02.wav rate
    
    • status: open --> closed-invalid
     
  • Mans Rullgard

    Mans Rullgard - 2018-04-28

    Closing since there was apparently no bug.

     

Log in to post a comment.