function edlwrite(N,F,T,S)
% edlwrite(N,F,T,S)
%   Write a MEAPsoft edit decision list file
%   N is the file to be written to.  Each line has form:
%     desttime  filename  starttime dur
%   F is a cell array of the filenames for each segment.
%   T is rows giving the <start dur> of each segment
%   Optional S gives the destination start times of each dur, else 
%   they are just stacked end-to-end from zero.
% 2006-03-27 dpwe@ee.columbia.edu MEAPsoft

nseg = size(T,1);

if nargin < 4
  S = cumsum([0,T(1:(nseg-1),2)']);
end

h = fopen(N,'w');

for i = 1:nseg
  fprintf(h, '%f %s %f %f\n', S(i),F{i},T(i,1),T(i,2));
end

fclose(h);

