function s = annotateSound(y, fs, onsets, filename)

% Write the whole original sound to the specified file with sonic
% markers around the onsets.

lead = round(.25*fs);
dur = round(.05*fs);
freq = 1000;

y = y(:);

for i=1:length(onsets)
  y(onsets(i)-lead:onsets(i)-lead+dur) = ...
      y(onsets(i)-lead:onsets(i)-lead+dur) + 0.05*sin(2*pi*freq/fs*[0:dur])';
end

wavwrite(y, fs, filename);

if(nargout > 0) s = y; end