annotate chordtools/checklabsyntax.m @ 1:8973548174c1 tip

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