annotate _chordtools/notes2pitchclasses.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 %
matthiasm@8 2 %NOTES2PITCHCLASSES convert a note list to an array pitchclasses
matthiasm@8 3 %
matthiasm@8 4 % [pitchclasses, success, errormessage] = notes2pitchclasses(notes, {verbose})
matthiasm@8 5 %
matthiasm@8 6 % Converts a cell array of note strings to an array of pitch class integer
matthiasm@8 7 % values. Pitch class values are referenced w.r.t. C = 0.
matthiasm@8 8 %
matthiasm@8 9 % Success = 1 if symbols converted correctly, 0 otherwise.
matthiasm@8 10 %
matthiasm@8 11 % If optional argument 'verbose' is 1, function prints any errormessage to
matthiasm@8 12 % the screen.
matthiasm@8 13 %
matthiasm@8 14 % calls note2pitchclass
matthiasm@8 15 %
matthiasm@8 16 % returns: pitchclasses (array of integers)
matthiasm@8 17 % success (boolean)
matthiasm@8 18 % errormessage (string)
matthiasm@8 19 %
matthiasm@8 20 %
matthiasm@8 21 % Author: Christopher Harte, August 2005
matthiasm@8 22 %
matthiasm@8 23 % Copyright: Centre for Digital Music, Queen Mary University of London 2005
matthiasm@8 24 %
matthiasm@8 25 % This file is part of the C4DM Chord Toolkit.
matthiasm@8 26 %
matthiasm@8 27 % The C4DM Chord Toolkit is free software; you can redistribute it and/or
matthiasm@8 28 % modify it under the terms of the GNU General Public License as published
matthiasm@8 29 % by the Free Software Foundation; either version 2 of the License, or
matthiasm@8 30 % (at your option) any later version.
matthiasm@8 31 %
matthiasm@8 32 % The C4DM Chord Toolkit is distributed in the hope that it will be useful,
matthiasm@8 33 % but WITHOUT ANY WARRANTY; without even the implied warranty of
matthiasm@8 34 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
matthiasm@8 35 % GNU General Public License for more details.
matthiasm@8 36 %
matthiasm@8 37 % You should have received a copy of the GNU General Public License
matthiasm@8 38 % along with the C4DM Toolkit; if not, write to the Free Software
matthiasm@8 39 % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
matthiasm@8 40 %
matthiasm@8 41
matthiasm@8 42 function [pitchclasses, success, errormessage] = notes2pitchclasses(notes, verbose)
matthiasm@8 43
matthiasm@8 44 % set verbose default to 0
matthiasm@8 45 if nargin < 2
matthiasm@8 46 verbose = 0;
matthiasm@8 47 end
matthiasm@8 48
matthiasm@8 49 errormessage = '';
matthiasm@8 50
matthiasm@8 51 ilength = length(notes);
matthiasm@8 52
matthiasm@8 53 index = 1;
matthiasm@8 54
matthiasm@8 55 success = 1;
matthiasm@8 56
matthiasm@8 57 pitchclasses = [];
matthiasm@8 58
matthiasm@8 59 while index <= ilength
matthiasm@8 60
matthiasm@8 61 [pitchclasses(index), success, errormessage] = note2pitchclass(char(notes(index)));
matthiasm@8 62
matthiasm@8 63 if success
matthiasm@8 64 index=index+1;
matthiasm@8 65 else
matthiasm@8 66 errormessage = [errormessage sprintf(['Error in notes2pitchclasses: couldn''t convert notes "' notes '"\n'])];
matthiasm@8 67 index = ilength +1;
matthiasm@8 68 end
matthiasm@8 69
matthiasm@8 70
matthiasm@8 71 end
matthiasm@8 72
matthiasm@8 73 if (success == 0) && (verbose == 1)
matthiasm@8 74
matthiasm@8 75 fprintf(1,errormessage)
matthiasm@8 76
matthiasm@8 77 end
matthiasm@8 78
matthiasm@8 79
matthiasm@8 80