function outwave=vibrato(inwave,fs,Modfreq,Width)



Delay=Width; % basic delay of input sample in sec
DELAY=round(Delay*fs); % basic delay in # samples
WIDTH=round(Width*fs); % modulation width in # samples
if WIDTH>DELAY 
  error('delay greater than basic delay !!!');
  return;
end
MODFREQ=Modfreq/fs; % modulation frequency in # samples
LEN=length(inwave);        % # of samples in WAV-file
L=2+DELAY+WIDTH*2;    % length of the entire delay  
Delayline=zeros(L,1); % memory allocation for delay
outwave=zeros(size(inwave));     % memory allocation for output vector
for n=1:(LEN-1)
   M=MODFREQ;
   MOD=sin(M*2*pi*n);
   TAP=1+DELAY+WIDTH*MOD;
   i=floor(TAP);
   frac=TAP-i;
   Delayline=[inwave(n);Delayline(1:L-1)]; 
   %---Linear Interpolation-----------------------------
   outwave(n,1)=Delayline(i+1)*frac+Delayline(i)*(1-frac);
end  


% Adapted from:
% Udo Zölzer, ed. "DAFX: Digital Audio Effects". John Wiley & Sons, 2002, Chapter 3, pp. 68-69.
% ISBN: 0-471-49078-4.