function [D,SR] = mp3streamin_read(Y,N)
% [D,SR] = mp3streamin_read(Y,N)
%     Read in the next N frames of data from the open mp3stream
%     handle Y.
% 2014-02-19 Dan Ellis dpwe@ee.columbia.edu

SR = 44100;
CH = 2;

if N < 1
  % close the stream
  popenr(Y, -1);
else
  R = popenr(Y, N*CH, 'int16');
  % Convert to stereo frames of float
  N = length(R)/CH;
  D = reshape(double(R)/32768.0, CH, N)';
end
