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