%  STFT.M   H.G.Feichtinger,   5-23/25-1990 , Aug. 92  
% 
%  determines the STFT of a vector  over a lattice 
%  with lattice constants  a (time) and b (frequ)
%
%  STFT_f(ak,bm) is the output
%
%  USAGE: ST =  STFT(signal,window,a,b)
% 
%  See also:  ISTFT, TFFILT, PERBAS 
%  
% modificato: FM 18/11/2006 per funzionare con i programmi di GD

function   stf = stft(x,w,a,b);

if nargin < 3;  a = 1; b = 1; end; 
n = length(x); 

res = zeros(n/a,n/b); 
w1 = [ w zeros(1,n-length(w))]; 
ww1 =  [w1,w1];  

for jj = 1 :  n/a; 
  y  = x.* ww1( (n+1-(jj-1)*a)  :  (2*n  - (jj-1)*a)) ;
  y1 = perbas(y,b); 
  v = fft(y1);
  res(rem(jj-1+n/a/2,n/a)+1,:) = v; 
end;
stf = res.'; 


