Time compression-expansion using standard phase vocoder

Type : vocoder phase time stretching
References : Posted by Cournape
Linked file : vocoder.m
(this linked file is included below)
Notes :
Standard phase vocoder. For imporved techniques ( faster ), see paper of Laroche : "Improved phase vocoder time-scale modification of audio"
Laroche, J.; Dolson, M.
Speech and Audio Processing, IEEE Transactions on , Volume: 7 Issue: 3 , May 1999
Page(s): 323 -332
Comments
from : dsp[at]rymix[DOT]net
comment : Anyone know what language this is in? It really would be nice to understand the syntax.

from : null[AT]null[DOT]null
comment : It's matlab code see <a href="http://www.mathworks.com/">mathworks</a>. /Daniel

from : dsp[AT]rymix[DOT]net
comment : thanks =)

from : ericlee280[DOT]at[DOT]hotmail[DOT]com
comment : The code seems to contain an undefined variable lss_frame, can someone explain what this is?

from : yyc[AT]cad[DOT]el[DOT]yuntech[DOT]edu[DOT]tw
comment : The code seems to contain an undefined variable lss_frame, can someone explain what this is?

from : cournape[at]enst[dot]fr
comment : There is indeed an error in the script. I will post the correction to the administrator. For now, here is the correction. You have to replace lss_frame by Ls ( which is properly defined before the main loop in the script which is online ). When I checked the code, there can be also some out of range error for the output vector : a change in the max variable definition seems to solve the problem ( at least for overlapp below 0.75 ). replace max = (nb_frame-2)*La+Nfft by max = (nb_frame)*La+Nfft.

from : yyc[AT]cad[DOT]el[DOT]yuntech[DOT]edu[DOT]tw
comment : is it really follow this paper "Improved phase vocoder time-scale modification of audio"?? because i get the another source code for original phase vocoder on net, and the performence is better than the code.... it is let me confuse.... have anyone can slove my question? and thanks...... ps:the sorce code from"http://www.ee.columbia.edu/~dpwe/resources/matlab/pvoc/" .

from : roger[DOT]sanchez[AT]online[DOT]de
comment : If someone told me last month that I would have yet ANOTHER westibe I would become addicted to, I would not be pleased.But I have no regrets for my obsession with your page! This is amazing and I am incredibly proud of you.I would love to hear your thoughts of my river. A river that meets the ocean. She has more than one obstacle to push through before flowing into the sublime. A favorite English professor used the phrase fluid chaos the other day and all I could think about was this river, and your westibe.Can't wait for your insight!

from : info[AT]nickellsworth[DOT]com
comment : Hey Bets,Been thinking about you as Big Goose rises,<a href="http://wynbwlwotnl.com"> wnedor</a> if the sand bags are a worthy strategy. It's such a better season than the last time I saw you, let's go for a walk and talk soon. Much love, Carolyn PS. Love this site!

from : olof[DOT]ekstrom[AT]abc[DOT]se
comment : maybe this topic is too old but anyway i have an big qoutsien about the mixer and a have visired many flstudio community no one talk about .so i want to know if there s a way to have more than the only 4 sends channels in flstudio. in cubase and other daws you can set an infinite numbers of sends (prefader) but fl studio is the most very easy to use and powerful in the same time (for me). so if there is a way to have more than 4 prefader sends please someone tell me . http://uakmagtwrie.com [url=http://dmgnumi.com]dmgnumi[/url] [link=http://msfcxnplw.com]msfcxnplw[/link]

from : rpbkgrfyblw[AT]outlook[DOT]com
comment : QuotesChimp have only scratched the surface of the potential disputes that can arise between an insurance company and the injured party.

from : ekuebeg[AT]m[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/

from : izowrudaq[AT]w[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/

from : aproxu[AT]w[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/

from : uzemni[AT]m[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/

from : enapun[AT]m[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/

from : uvxize[AT]g[DOT]eamale[DOT]com
comment : [url=http://dapoxetine-onlinepriligy.net/]dapoxetine-onlinepriligy.net.ankor[/url] <a href="http://ventolinsalbutamol-buy.org/">ventolinsalbutamol-buy.org.ankor</a> http://ventolinsalbutamolbuy.org/


Linked files
function [S] = vocoder(E,Nfft,over,alpha)

% Phase vocoder time-scaling :

% - E     : input vector
% - Nfft  : size per frame
% - over  : overlapp ( between 0 et 1 )
% - alpha : time-expansion/compression factor ( alpha < 1 : compression; alpha > 1 : expansion ).
%
% 30.11.02. Cournapeau David.
%
% Time expansion using standart phase vocoder technique. Based on Dolson and Laroche's paper : 
% "NEW PHASE-VOCODER TECHNIQUES FOR PITCH-SHIFTING, HARMONIZING AND
% OTHER EXOTIC EFFECTS", in 


%===================================================================%
% The synthesis signal's length isn't exactly alpha*input's length. %
%===================================================================%


% Verifiy the overlapp

if( over < 0 | over >= 1 )
   error('error : overlapp must be between 0 and 1');
end;

if ( alpha <= 0)
    error('alpha must be strictly positive');
end;

E    = E(:);
N    = length(E);
Nfft = 2^(nextpow2(Nfft));

% Computing vocoder's parameters :
% - La        : number of samples to "advance" for each anamysis frame : analysis hop size.
% - nb_frames : number of frames to compute
% - Ls        : number of samples ot "advance" for each synthesis frame : synthesis hop size.
% - S         : S is the result vector
% - h         : hanning window

La        = floor((1-over) * Nfft);
nb_frames = floor((N-Nfft) / La);
max 	  = (nb_frames-2)*La + Nfft;
ls        = floor(alpha * La);

S         = zeros(floor(max*alpha),1);
h         = hanning(Nfft);

% Init process :

X     = h.*E(1:Nfft);
tX    = fft(X,Nfft);
Phis1 = angle(tX)
Phia1 = Phis1;

for loop=2:nb_frames-1
   
    %===============================================================================
    % ( classic analysis part of a phase vocoder )
    
    % Take a frame, and windowing it
    
    X  = h.*E((loop-1) * La + 1:(loop-1)*La + Nfft); 
   
    % XI is the amplitude spectrum, and Phia2 the phase spectrum.
    
    tX    = fft(X, Nfft);
	Xi    = abs(tX);
    Phia2 = angle(tX);
    
    %================================================================================
    % the part which actually does the time scaling
    
    % One compute the actual pulsations, and shift them. The tricky part is here...
    
    omega = mod( (Phia2-Phia1)-2*pi*([0:Nfft-1].')/Nfft * La + pi, 2*pi) - pi;
    omega = 2 * pi * ([0:Nfft-1].') / Nfft + omega / La;
    Phis2 = Phis1 + lss_frame*omega;
 
    % The new phases values  :
    
    Phis1 = Phis2;
    Phia1 = Phia2;
    
    %==============================================================================
    %  Synthetise the frame, thanks to the computed phase and amplitude spectrum :
    % ( classic synthetisis part of a phase vocoder )
    
    tfs = Xi.*exp(j*Phis2);
    Xr  = real(ifft(tfs)).*h;
    
    % overlapp-add the synthetised frame Xr 
    
    S((loop-1)*lss_frame+1:(loop-1)*lss_frame+Nfft) ...
      = S((loop-1)*lss_frame+1:(loop-1)*lss_frame+Nfft) + Xr;
    
end;