A Matlab Implementation of the Phase Vocoder

A discussion of basic phase vocoding technology is given here with a more detailed pdf version here. This page shows my implementation in Matlab, which you may find useful for experimentation. The "help" file for PV.m reads:

 % This implements a phase vocoder for time-stretching/compression % Put the file name of the input file in "infile" % the file to be created is "outfile" % The amount of time-stretch is determined by the ratio of the hopin % and hopout variables. For example, hopin=242 and hopout=161.3333 % (integers are not required) increases the tempo by % hopin/hopout = 1.5. To slow down a comparable amount, % choose hopin = 161.3333, hopout = 242. % 5/2005 Bill Sethares

As you can see, the phase vocoder reads in a .wav file, time-stretches (or time-compresses) it, and then writes the resulting sound to another .wav file that you can listen to using any audio program capable of playing .wav files.. To run this yourself, you will need to place the main routine PV.m and the subroutine findPeaks.m in the Matlab path. [findPeaks.m is a slightly modified version of a subroutine written by P. Moller-Nielson, who also has an excellent sounding phase vocoder implementation along with some very clear documentation.] Renrick Tulloch has translated the PV code for compatibility with Octave.

Besides the hopin and hopout variables (which together specify the amount of stretching or compressing), there are a number of variables that you can experiment with to change the sound:

time: specifies the number of seconds of the input file to process
nfft: the FFT (frame) size. This must be a power of two. Larger values give smoother results, shorter values give better transients.
max_peak: maximum number of peaks to look for
eps_peak: minimum height of peaks

So that you can check to see that everything is working, here are the first few bars of Scott Joplin's Maple Leaf Rag. Using the default values for all variables, you can time-stretch this by a factor of two by setting hopin=121 and hopout=242. The result is the SlowMaple (I have converted the output from .wav to .mp3 format to save time uploading and downloading.). Alternatively, you can speed it up by a factor of two by setting hopin=242 and hopout=121. Here is the FastMaple. (You may need to right click to download these files). Good luck, and have fun stretching and compressing your favorite sounds...