For the saxophone music classes I'm taking, I have some exercises to play along with Charlie Parker records. Because that Bird plays pretty fast, it helps to slow things down a bit. I started with manually slowing down the tempo with Audacity, but soon I couldn't suppress the itch to automate things as I needed several slow down factors and also wanted the slow down factor in the MP3 ID3 title tag.

Here is the bash for loop I use now, mainly for my own reference (copy, edit and paste in terminal), but I guess it might be interesting in some form for other people as well.

input=perhaps.mp3
slowdowns="0.95 0.90 0.85 0.80 0.75 0.70 0.60"

# Additional sox options, e.g. "trim 80 30" to extract fragment from 1:20 to 1:50
soxoptions=""

for tempo in $slowdowns; do
  output=${input%.mp3}-tempo$tempo.mp3
  echo "$tempo slowing down $input to $output"
  sox $input $output $soxoptions tempo $tempo
  title=$(id3v2 --list $output | awk -F ': ' '/TIT2/ { print $2 }')
  percent=$(echo "scale=0; $tempo * 100/1" | bc -l)
  id3v2 --song "$title ($percent%)" $output
  echo done
done

This will generate files perhaps-tempo0.95.mp3, perhaps-tempo0.90.mp3, etc.

Dependencies:

  • SoX for slowing down the audio. I installed it on my Mac with Macports (port "sox")
  • id3v2 for appending the slow down factor to the MP3 ID3V2 title tag. Also installed with Macports (port "id3v2").