% FUNCTION Y = FRAME_MIDDLE(N_SAMPLES, FRAME_LENGTH, [FRAME_SHIFT])
%
% default frame_shift = frame_length/2
%
% Returns vector of middle sample of each frame, in samples.

function y = frame_middle(n_samples, frame_length, frame_shift)

if nargin < 2
  frame_length = 512;
end

if nargin < 3
  frame_shift = floor(frame_length / 2);
end

n_frames = 1 + floor((n_samples - frame_length) / frame_shift);
y = frame_length / 2 + frame_shift * (0:n_frames-1);
