0

I need to run a script in python that changes the tempo of an MP3 song without changing the pitch.

I've seen Soundstretch but it only works with wav files and I wanted to avoid having to convert back and forth.

How can I do the pitch-shifting without converting to WAV?

slhck
  • 223,558
  • 70
  • 607
  • 592
West
  • 103
  • 3
  • Note that I edited your question since 1) asking for tool recommendations is considered off topic here, and 2) opinion-based questions like your second one are not encouraged (and anyway, there should be one question at a time). – slhck Nov 28 '19 at 15:03
  • Got it, cheers for the edit – West Nov 28 '19 at 15:08

1 Answers1

2

Changing the tempo of a song always requires re-sampling. Speeding up or slowing down is simply done by reducing or increasing the space between individual audio samples. That also changes the pitch, since the heard frequencies will be higher or lower.

Now, if you want to change the pitch (that is, keep the original) of a tempo-stretched/squeezed song, you will actually have to touch the content of the samples and pitch-shift it. This means decoding, processing, and, consequently, re-encoding to a file.

So, to summarize, there's no way around re-encoding, unless you can do the time-stretching live, during playback.

slhck
  • 223,558
  • 70
  • 607
  • 592
  • Thanks for the prompt response and the link which has also helped me understand more. I will have to do with converting back and forth. Do you reckon quality is affected significantly by converting an mp3 to wav, time-stretching and then converting back to mp3? – West Nov 28 '19 at 15:13
  • It should be fine as long as your final MP3 file is encoded with the same, or preferably a higher bitrate, or VBR with a high quality setting. – slhck Nov 28 '19 at 15:15
  • Awesome., I'll get onto it cheers – West Nov 28 '19 at 15:21