Category Archives: How-To’s

Use sox to adjust tempo and gain (volume)

sox is a command line tool to play, record, split, adjust effects and convert audio files. sox probably does other things, but those are the sox features I’ve used.

A simple command line invocation can adjust the tempo and gain of .mp3 or .ogg files in a particular directory. cd into the directory and do:

$ for i in *{ogg,mp3}; do sox "$i" "${i%.*}.new.ogg" tempo 1.48 gain 6; done

Tempo is the playback speed. Increasing tempo will play the file faster without making the speakers sound like Mickey Mouse.

That will loop through all the .ogg and .mp3 files in the directory and for each .ogg and each .mp3 file, use sox to increase the tempo 1.48 times (+48%) and increase the volume. Adjust to your needs. The sox‘ed files will be converted to .ogg files with the same filename but instead of having the old extension, the sox‘ed .mp3 and .ogg files will have the extension .new.ogg . The double quotes are to handle filenames with spaces or other special characters. I increase the volume since some podcasts’ volume levels are so low that on my drive to work, if I don’t increase the volume, I can’t make out the talk even with the volume turned all the way up

If you use bash, running the command should put the command in your ~/.bash_history, so recalling the command is a simple ctrl-r away.

sox‘s man page is helpful, not only in jogging your memory, but in explaining the command’s options. There aren’t any examples I could find in the man page, though, but your favorite search engine should help.