I recently compared the two to decide which one to use in my Scaper soundscape synthesis and augmentation library, and figured I'd share what I found here in case anyone finds it helpful.
Sox and Rubberband are two excellent open-source command-line tools for audio processing. Both have python wrappers too: pysox and pyrubberband.
Both sox and rubberband provide optional arguments that allow you to fine tune the shifting/stretching algorithm for the specific audio content being processed. In my very quick and dirty (and non-comprehensive) exploration, I found one setting for sox and one setting for rubberband that generally gave the best sounding results (to my ears), so I used the same setup for all comparisons below.
âIn all the audio examples below, the following commands were used:
Pitch shifting:
- sox infile.wav outfile.wav pitch 100
- rubberband --pitch 1 infile.wav outfile.wav -c 6
Time stretching:
- sox infile.wav outfile.wav tempo -s 0.833
- rubberband --time 1.2 infile.wav outfile.wav -c 6
I strongly recommend listening to the examples below with good headphones, since the differences are sometimes quite subtle (but definitely noticeable with a good pair of cans).
Speech
Pitch shift: Sox
Pitch shift: Rubberband
Time stretch: Sox
Time stretch: Rubberband
Engine
Pitch shift: Sox
Pitch shift: Rubberband
Time stretch: Sox
Time stretch: Rubberband
Music: male voice
Pitch shift: Sox
Pitch shift: Rubberband
Time stretch: Sox
Time stretch: Rubberband
âMusic: female voice
Pitch shift: Sox
Pitch shift: Rubberband
Time stretch: Sox
Time stretch: Rubberband
So... which one's better? Like most things in life, it depends. It depends on your target application and what matters most in that context, it depends whether you're only doing pitch shifting or time stretching or both, it depends on your audio content, the parameters you choose...
For my application I have a relatively clear winner, but I won't bias you with my opinion ;)