function xx=block_fft(in,len)
% block_fft(in, len)
% Calculates windowed FFT (length len, with 50% overlap),
% then inverse FFT with overlap-add. If not processing is inserted
% into the function below, the output should be essentially identical
% to the input.
%
% in = input data vector
% len = desired fft length (e.g., 1024)
% xx = output data vector
in=in(:);
% Create output buffer for overlap add
xx=zeros(1,length(in));
% Create length �len� raised cosine window function
wind=0.5*(1-cos(2*pi*(0:len-1)/len));
% Stride through the input with 50% overlap (len/2),
% calculate windowed length �len� FFT of each block,
% then inverse transform and overlap-add.
for i=1:len/2:(length(in)-len)
ff=fft(wind.*in(i:(i+len-1))',len);
% User processing of FFT data would go here�
xx(i:(i+len-1))= xx(i:(i+len-1))+ ifft(ff,len);
end