function N = mp3streamout_write(Y,D)
% N = mp3streamout_write(Y,D)
%    Write the next chunk of data to an output MP3 file.  Empty D
%    means close output.
% 2014-02-19 Dan Ellis dpwe@ee.columbia.edu

if isempty(D)
  popenw(Y,D);
  N = -1;
else
%  iD = int16(D'*32768.0);
%  iD = iD(:);
%  popenw(Y,iD,'int16le');
  % Current popenw wants to convert floats to int16s internally...
  popenw(Y,D'*32768.0,'int16le');
  N = size(D,1);
end
