Playing a piece of music audio at a slower speed would lower its pitch (frequency). Is there a tool and theory to slow down the song playing while keep the frequency the same? I suppose one can do windowed Fourier transform or wavelet transform. It seems one have to either pre-select the window size or dynamically choose the wavelet basis. Is there any specific and detailed theory and application for doing that?
Yeah some of us can do it, you can speed up or slow down without affect the pitch, some guys call this applications of Time Stretch, there different ways to do it, you can do in frequency domain or time domain, you will need choose what is best for you, you will find some advantages and disadvantages of each.
In Time Domain you can try some techniques like:
- TDHS(Time domain Harmonic Sacaling)
- SOLA (Synchronous Overlap Add)
- PSOLA(Pitch Synchronous Overlap Add)
- WSOLA(Waveform Similarity Overlap Add)
Pros: Is fast, some algorithms are easy to understand, good quality in monophonic sounds.
Cons: Generally you'll need a very nice pitch track to splice in the right position, it is hard to do :-(, so if your pitch track fails or not work in Poliphonic sounds this algorithms will give a lot of glitches/artifacts in the output sound.
All time stretch that i know in frequency domain are based in phase vocoder techniques.
Pros: Will work in polyphonic or monophonic sounds.
Cons: Can be painful understand all the math, implementation is a bit hard, is not so fast like time domain codes, for voice i prefer time domain results, some tricks to improve the result of the standard phase vocoder are not shared.
I can say that the window and the hop size are one of the key for the phase vocoder quality, generally we choose
4x overlap to resynthesis, one hann window of size
4096 is enough for my ears (of course if u have processing power for this sizes), the standard phase vocoder can add some reverberant effetcts, to try avoid this kind of problems you maybe need lock the phase.
The tool/theory you describe is really a large area of research in music technology, broadly called audio time-scale modification. A large component of this field is how you might prevent audible changes to frequency following time stretching. This can be approached with both frequency- and time-domain methods, depending on the constraints or goals of your application. The wikipedia entry for Audio time-scale / pitch modification is a good starting point.
If you're keen to pursue an approach using frequency/wavelet basis, your window-size and choice of basis will affect how well you're able to localise the signal. To use the STFT as an example, a long window will perform well for stationary sinusoids but destroy your transients. A shorter window will provide a preferable transient response at the cost of frequency-domain localisation. The performance of other wavelet bases will depend on the nature of the projection of your signal onto the basis.
Below is a link to a simple and valuable tutorial function in C++ (smbPitchShift.cpp) by Stephan M. Bernsee, which can slow-down or speed-up music without changing its pitch.
He has released this code under the The Wide Open License (WOL). Within my application, I was able to adapt his function to slow-down music in real-time -- that is while playing a mp3 file and additionally doing pitch detection upon that mp3 signal at the same time.
I have also included a link to Bernsee's website which contains his detailed descriptions on the Time-Stretching and Pitch-Shifting of audio signals, such as music.