matthiasm@8: % matthiasm@8: % CHECKLABSYNTAX Check the syntax of all chords in a lab file matthiasm@8: % matthiasm@8: % [success] = checklabsyntax(labfile, {fid}) matthiasm@8: % matthiasm@8: % Checks syntax of all chord symbols in a lab file. Any incorrect chords matthiasm@8: % will produce syntax errors and be quoted with time of chord from the matthiasm@8: % labfile given for inspection. matthiasm@8: % matthiasm@8: % fid is the file id of the output log file. If not given, the error log matthiasm@8: % will be printed to the screen matthiasm@8: % matthiasm@8: % Success = 1 if all symbols have correct syntax, 0 otherwise. matthiasm@8: % matthiasm@8: % Returns: success (boolean) matthiasm@8: % matthiasm@8: % matthiasm@8: % Author: Christopher Harte, August 2005 matthiasm@8: % matthiasm@8: % Copyright: Centre for Digital Music, Queen Mary University of London 2005 matthiasm@8: % matthiasm@8: % This file is part of the C4DM Chord Toolkit. matthiasm@8: % matthiasm@8: % The C4DM Chord Toolkit is free software; you can redistribute it and/or matthiasm@8: % modify it under the terms of the GNU General Public License as published matthiasm@8: % by the Free Software Foundation; either version 2 of the License, or matthiasm@8: % (at your option) any later version. matthiasm@8: % matthiasm@8: % The C4DM Chord Toolkit is distributed in the hope that it will be useful, matthiasm@8: % but WITHOUT ANY WARRANTY; without even the implied warranty of matthiasm@8: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the matthiasm@8: % GNU General Public License for more details. matthiasm@8: % matthiasm@8: % You should have received a copy of the GNU General Public License matthiasm@8: % along with the C4DM Toolkit; if not, write to the Free Software matthiasm@8: % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA matthiasm@8: matthiasm@8: % matthiasm@8: function [success] = checklabsyntax(labfile,fid) matthiasm@8: matthiasm@8: if nargin < 2 matthiasm@8: fid = 1; matthiasm@8: end matthiasm@8: matthiasm@8: success = 1; matthiasm@8: matthiasm@8: [times1,t2,symbols] = labread(labfile); matthiasm@8: matthiasm@8: ilength = length(symbols); matthiasm@8: matthiasm@8: % new file matthiasm@8: fprintf(fid, ['*** File: ' labfile ' ***\n\n']); matthiasm@8: matthiasm@8: errormessage = ''; matthiasm@8: matthiasm@8: for index = 1:ilength matthiasm@8: matthiasm@8: [ok, errormessage] = syntaxcheck(char(symbols(index))); matthiasm@8: matthiasm@8: matthiasm@8: if ok == 0 matthiasm@8: matthiasm@8: success = 0; matthiasm@8: matthiasm@8: fprintf(fid,['Time: %f seconds\n' errormessage '\n\n'], times1(index)); matthiasm@8: matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: