matthiasm@8: % matthiasm@8: %NOTE2FIFTHPOSITION find note position on the line of fifths w.r.t. C=0 matthiasm@8: % matthiasm@8: % [noteposition, success, errormessage] = note2fifthposition(note,{verbose}) matthiasm@8: % matthiasm@8: % Converts a note string to a natural position on the line of fifths and its matthiasm@8: % corresponding number of sharps or flats. Reference on line of fifths is C = 0. matthiasm@8: % matthiasm@8: % Success = 1 if note converted correctly, 0 otherwise. matthiasm@8: % matthiasm@8: % If optional argument 'verbose' is 1, function prints any errormessage to matthiasm@8: % the screen. matthiasm@8: % matthiasm@8: % calls: note2fifthinfo matthiasm@8: % matthiasm@8: % returns: noteposistion (integer) matthiasm@8: % success (boolean) matthiasm@8: % errormessage (string) matthiasm@8: % matthiasm@8: % matthiasm@8: % Author: Christopher Harte, September 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 [noteposition, success, errormessage] = note2fifthposition(note, verbose) matthiasm@8: matthiasm@8: % set verbose default to 0 matthiasm@8: if nargin < 3 matthiasm@8: verbose = 0; matthiasm@8: end matthiasm@8: matthiasm@8: errormessage = ''; matthiasm@8: success = 1; matthiasm@8: noteposition = ''; matthiasm@8: matthiasm@8: [notenatural, noteaccidentals, success1,errormessage] = note2fifthinfo(note); matthiasm@8: matthiasm@8: if success matthiasm@8: noteposition = notenatural + 7.*noteaccidentals -1; matthiasm@8: end matthiasm@8: matthiasm@8: if (success == 0) && (verbose == 1) matthiasm@8: fprintf(1,errormessage); matthiasm@8: end matthiasm@8: