% 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 clear; clf infile='yoursong.wav'; outfile='yoursongchanged'; time=0; % total time to process hopin=121; % hop length for input hopout=242; % hop length for output all2pi=2*pi*(0:100); % all multiples of 2 pi (used in PV-style freq search) max_peak=50; % parameters for peak finding: number of peaks eps_peak=0.005; % height of peaks nfft=2^12; nfft2=nfft/2; % fft length win=hanning(nfft)'; % windows and windowing variables [y,sr]=wavread(infile); % read song file siz=wavread(infile,'size'); % length of song in samples stmo=min(siz); leny=max(siz); % stereo (stmo=2) or mono (stmo=1) if siz(2)