comparison chordtools/labwrite.m @ 1:8973548174c1 tip

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