christopherh@1
|
1 %
|
christopherh@1
|
2 % CHORD2QUALITY return the chord quality of a given chord symbol
|
christopherh@1
|
3 %
|
christopherh@1
|
4 % [quality,success, errormessage] = chord2quality(chordsymbol, {verbose})
|
christopherh@1
|
5 %
|
christopherh@1
|
6 % Returns the chord quality of a given chord symbol. Quality values are from
|
christopherh@1
|
7 % the enumeration:
|
christopherh@1
|
8 %
|
christopherh@1
|
9 % 0 Major
|
christopherh@1
|
10 % 1 Minor
|
christopherh@1
|
11 % 2 Diminished
|
christopherh@1
|
12 % 3 Augmented
|
christopherh@1
|
13 % 4 Suspended
|
christopherh@1
|
14 %
|
christopherh@1
|
15 % Success = 1 if symbols parsed correctly, 0 otherwise.
|
christopherh@1
|
16 %
|
christopherh@1
|
17 % If optional argument 'verbose' is 1, function prints any errormessage to
|
christopherh@1
|
18 % the screen.
|
christopherh@1
|
19 %
|
christopherh@1
|
20 % calls: getchordinfo
|
christopherh@1
|
21 % short2quality
|
christopherh@1
|
22 % intervals2quality
|
christopherh@1
|
23 %
|
christopherh@1
|
24 % returns: quality (integer)
|
christopherh@1
|
25 % success (boolean)
|
christopherh@1
|
26 % errormessage (string)
|
christopherh@1
|
27 %
|
christopherh@1
|
28 %
|
christopherh@1
|
29 % Author: Christopher Harte, March 2009
|
christopherh@1
|
30 %
|
christopherh@1
|
31 % Copyright: Centre for Digital Music, Queen Mary University of London 2005
|
christopherh@1
|
32 %
|
christopherh@1
|
33 % This file is part of the C4DM Chord Toolkit V2.0
|
christopherh@1
|
34 %
|
christopherh@1
|
35 % The C4DM Chord Toolkit is free software; you can redistribute it and/or
|
christopherh@1
|
36 % modify it under the terms of the GNU General Public License as published
|
christopherh@1
|
37 % by the Free Software Foundation; either version 2 of the License, or
|
christopherh@1
|
38 % (at your option) any later version.
|
christopherh@1
|
39 %
|
christopherh@1
|
40 % The C4DM Chord Toolkit is distributed in the hope that it will be useful,
|
christopherh@1
|
41 % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
christopherh@1
|
42 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
christopherh@1
|
43 % GNU General Public License for more details.
|
christopherh@1
|
44 %
|
christopherh@1
|
45 % You should have received a copy of the GNU General Public License
|
christopherh@1
|
46 % along with the C4DM Toolkit; if not, write to the Free Software
|
christopherh@1
|
47 % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
christopherh@1
|
48
|
christopherh@1
|
49 %
|
christopherh@1
|
50
|
christopherh@1
|
51 function [quality, success, errormessage] = chord2quality(chordsymbol,verbose)
|
christopherh@1
|
52
|
christopherh@1
|
53 quality = 0;
|
christopherh@1
|
54 errormessage = '';
|
christopherh@1
|
55
|
christopherh@1
|
56 if nargin < 2
|
christopherh@1
|
57 verbose = 0;
|
christopherh@1
|
58 end
|
christopherh@1
|
59
|
christopherh@1
|
60 [rootnote,shorthand,interval_list,bassinterval,success,error] = getchordinfo(chordsymbol);
|
christopherh@1
|
61
|
christopherh@1
|
62 if success
|
christopherh@1
|
63
|
christopherh@1
|
64 if ~isempty(shorthand)
|
christopherh@1
|
65
|
christopherh@1
|
66 [quality, success, error] = short2quality(shorthand);
|
christopherh@1
|
67
|
christopherh@1
|
68 else
|
christopherh@1
|
69
|
christopherh@1
|
70 [quality, success, error] = intervals2quality(interval_list);
|
christopherh@1
|
71
|
christopherh@1
|
72 end
|
christopherh@1
|
73
|
christopherh@1
|
74 end
|
christopherh@1
|
75
|
christopherh@1
|
76
|
christopherh@1
|
77
|
christopherh@1
|
78 if(success==0)
|
christopherh@1
|
79
|
christopherh@1
|
80 errormessage = sprintf([error 'Error in Chord2quality: Chord "' chordsymbol '"\n']);
|
christopherh@1
|
81
|
christopherh@1
|
82 if verbose == 1
|
christopherh@1
|
83 fprintf(1, errormessage);
|
christopherh@1
|
84 end
|
christopherh@1
|
85 end |