Martin Guy - 2025-12-27

Hi! I've had a look at this and it seems that the reason is that "speed" changes the sample rate but the call to sox_open_write() specifies the sample rate of the output file as a copy of that of the input file.
It is sox.c, which is "just" another client of libsox, that automatically inserts effects in the chain to adapt the sample rate at the end, make the number of channels match, not libsox, which is why it works from the command line as you expected.
If you add a "rate 48000" (or whatever the sample rate of the output file is) after the "speed", you get the output you expected, or you can achieve the "speed" effect you wanted simply by multiplying or dividing in->signal.rate by the factor in question before copying it into out->signal.rate without any "speed" effect at all.

https://codeberg.org/sox_ng/sox_ng/issues/442

 

Last edit: Martin Guy 2025-12-27