Mercurial > hg > c4dm-chord-transcriptions
comparison chordtools/checklabsyntax.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 % CHECKLABSYNTAX Check the syntax of all chords in a lab file | |
3 % | |
4 % [success] = checklabsyntax(labfile, {fid}) | |
5 % | |
6 % Checks syntax of all chord symbols in a lab file. Any incorrect chords | |
7 % will produce syntax errors and be quoted with time of chord from the | |
8 % labfile given for inspection. | |
9 % | |
10 % fid is the file id of the output log file. If not given, the error log | |
11 % will be printed to the screen | |
12 % | |
13 % Success = 1 if all symbols have correct syntax, 0 otherwise. | |
14 % | |
15 % Returns: success (boolean) | |
16 % | |
17 % | |
18 % Author: Christopher Harte, March 2009 | |
19 % | |
20 % Copyright: Centre for Digital Music, Queen Mary University of London 2005 | |
21 % | |
22 % This file is part of the C4DM Chord Toolkit V2.0 | |
23 % | |
24 % The C4DM Chord Toolkit is free software; you can redistribute it and/or | |
25 % modify it under the terms of the GNU General Public License as published | |
26 % by the Free Software Foundation; either version 2 of the License, or | |
27 % (at your option) any later version. | |
28 % | |
29 % The C4DM Chord Toolkit is distributed in the hope that it will be useful, | |
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of | |
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
32 % GNU General Public License for more details. | |
33 % | |
34 % You should have received a copy of the GNU General Public License | |
35 % along with the C4DM Toolkit; if not, write to the Free Software | |
36 % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
37 | |
38 % | |
39 function [success] = checklabsyntax(labfile,fid) | |
40 | |
41 if nargin < 2 | |
42 fid = 1; | |
43 end | |
44 | |
45 success = 1; | |
46 | |
47 [times1,t2,symbols] = labread(labfile); | |
48 | |
49 ilength = length(symbols); | |
50 | |
51 % new file | |
52 fprintf(fid, ['*** File: ' labfile ' ***\n\n']); | |
53 | |
54 errormessage = ''; | |
55 | |
56 for index = 1:ilength | |
57 | |
58 [ok, errormessage] = syntaxcheck(char(symbols(index))); | |
59 | |
60 | |
61 if ok == 0 | |
62 | |
63 success = 0; | |
64 | |
65 fprintf(fid,['Time: %f seconds\n' errormessage '\n\n'], times1(index)); | |
66 | |
67 end | |
68 end | |
69 | |
70 |