function y = applyeditlist(d,sr,editlist)
% y = applyeditlist(d,sr,editlist)
%   d,sr is input audio.  <editlist> is a series of edit
%   instructions of the form:
%    <srcstart> <dststart> <dur>
%   meaning that the regions <srcstart>..<srcstart+dur> should be
%   placed at <dststart>..<dststart+dur> in the output y.
% 2013-12-30 Dan Ellis dpwe@ee.columbia.edu

nedits = size(editlist, 1);

srcstarts = editlist(:,1);
dststarts = editlist(:,2);
durs = editlist(:,3);

maxdur = max(dststarts + durs);

y = zeros(ceil(maxdur*sr), 1);

for i = 1:nedits
  nsamps = round(durs(i)*sr);
  sampx = [1:nsamps];
  y(round(dststarts(i)*sr)+sampx) = ...
      d(round(srcstarts(i)*sr)+ sampx);
end

  
  