Mercurial > hg > c4dm-chord-transcriptions
view chordtools/interval2rcclass.m @ 1:8973548174c1 tip
adding tools to repo
author | christopherh |
---|---|
date | Mon, 06 May 2013 14:43:47 +0100 |
parents | |
children |
line wrap: on
line source
% % INTERVAL2RCCLASS convert an interval to relative pitchclass displacement % % [rcclass,success, errormessage] = interval2rcclass(interval, {verbose}) % % Converts an interval string to relative pitchclass displacement. % % Success = 1 if symbols parsed correctly, 0 otherwise. % % If optional argument 'verbose' is 1, function prints any errormessage to % the screen. % % calls: parseinterval % degree2semitone % % returns: rcclass (integer) % success (boolean) % errormessage (string) % % % Author: Christopher Harte, January 2010 % % Copyright: Centre for Digital Music, Queen Mary University of London 2005 % % This file is part of the C4DM Chord Toolkit V2.0 % % The C4DM Chord Toolkit is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as published % by the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % The C4DM Chord Toolkit is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with the C4DM Toolkit; if not, write to the Free Software % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA % function [rcclass, success, errormessage] = interval2rcclass(interval, verbose) if nargin <2 % verbose defaults 0 verbose = 0; end errormessage = ''; ilength = length(interval); success=0; semitone = 0; % parse the interval string [degree, accidentals, present, ok,errormessage] = parseinterval(interval); if (ok == 1) % convert degree and accidentals to equivalent number of semitones [semitone, ok, errors] = degree2semitone(degree,accidentals); rcclass = mod(semitone,12); success = 1; else errormessage = sprintf([errormessage 'Error in interval2rcclass: incorrect interval "' interval '"\n']); end if (verbose ==1) && (success ==0) fprintf(1,errormessage); end