annotate _chordtools/labwrite.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 %
matthiasm@8 2 %LABWRITE write a labfile to disk
matthiasm@8 3 %
matthiasm@8 4 % labwrite(times1, times2, labels, labfile, {protect})
matthiasm@8 5 %
matthiasm@8 6 % Write time indices and labels to a wavesurfer .lab transcription file
matthiasm@8 7 % with file name labfile
matthiasm@8 8 %
matthiasm@8 9 % If optional argument 'protect' is 1 then if a lab file of the given name
matthiasm@8 10 % already exists it will be copied to a backup file with extension '.labx'
matthiasm@8 11 % before writing new data to the lab file
matthiasm@8 12 %
matthiasm@8 13 % See also labread, mlf2lab, checklabsyntax.
matthiasm@8 14 %
matthiasm@8 15 % Author: Christopher Harte, August 2005
matthiasm@8 16 %
matthiasm@8 17 % Copyright: Centre for Digital Music, Queen Mary University of London 2005
matthiasm@8 18 %
matthiasm@8 19 % This file is part of the C4DM Chord Toolkit.
matthiasm@8 20 %
matthiasm@8 21 % The C4DM Chord Toolkit is free software; you can redistribute it and/or
matthiasm@8 22 % modify it under the terms of the GNU General Public License as published
matthiasm@8 23 % by the Free Software Foundation; either version 2 of the License, or
matthiasm@8 24 % (at your option) any later version.
matthiasm@8 25 %
matthiasm@8 26 % The C4DM Chord Toolkit is distributed in the hope that it will be useful,
matthiasm@8 27 % but WITHOUT ANY WARRANTY; without even the implied warranty of
matthiasm@8 28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
matthiasm@8 29 % GNU General Public License for more details.
matthiasm@8 30 %
matthiasm@8 31 % You should have received a copy of the GNU General Public License
matthiasm@8 32 % along with the C4DM Toolkit; if not, write to the Free Software
matthiasm@8 33 % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
matthiasm@8 34 %
matthiasm@8 35
matthiasm@8 36 function labwrite(times1, times2, labels, labfile, protect)
matthiasm@8 37
matthiasm@8 38 if nargin<5
matthiasm@8 39 protect = 0;
matthiasm@8 40 end
matthiasm@8 41
matthiasm@8 42 if (protect == 1)
matthiasm@8 43 check = copyfile(labfile, [labfile 'x']);
matthiasm@8 44 end
matthiasm@8 45
matthiasm@8 46 fid = fopen(labfile, 'w');
matthiasm@8 47
matthiasm@8 48 for i = 1:length(times1)
matthiasm@8 49
matthiasm@8 50 outtext = ['%f %f ' char(labels(i)) '\n'];
matthiasm@8 51
matthiasm@8 52 fprintf(fid, outtext, times1(i), times2(i));
matthiasm@8 53
matthiasm@8 54 end
matthiasm@8 55
matthiasm@8 56 fclose(fid);
matthiasm@8 57
matthiasm@8 58