function X = parsesig(x, frame_sz, frame_incr)
% PARSESIG Compute short-time Fourier transform.
%
% X = PARSESIG(x, FRAME_SZ, FRAME_INCR) computes the short-time Fourier
% transform of the input signal x using a frame size of FRAME_SZ samples
% and a hop (i.e., increment) of FRAME_INCR samples. Each column of the
% output matrix X corresponds to the Fourier transform of one frame in x.
%
% Author: Steve Tjoa
% Institution: University of Maryland (Signals and Information Group)
% Created: June 30, 2009
% Last modified: July 9, 2009
%
% This code was written during the workshop on Music Information Retrieval
% at the Center for Computer Research in Music and Acoustics (CCRMA) at
% Stanford University.
% Initialize parameters.
N = length(x);
num_frames = floor((N-frame_sz)/frame_incr) + 1;
X = zeros(frame_sz, num_frames);
% Parse the input signal frame-by-frame.
i = 1;
for n = 1:num_frames
xfr = x(i:i+frame_sz-1);
X(:,n) = fft(xfr);
i = i + frame_incr;
end