matthiasm@8: function outnote = spellnote(key,root,varargin) matthiasm@8: if nargin > 2 matthiasm@8: type = varargin{1}; matthiasm@8: else matthiasm@8: type = 'normal'; matthiasm@8: end matthiasm@8: matthiasm@8: switch type matthiasm@8: case 'normal' matthiasm@8: if root ~= 13 matthiasm@8: scale{1} = {'C','C#','D','Eb','E','F','F#','G','Ab','A','Bb','B'}; matthiasm@8: scale{2} = {'Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B','C'}; matthiasm@8: scale{3} = {'D','D#','E','F','F#','G','G#','A','Bb','B','C','C#'}; matthiasm@8: scale{4} = {'Eb','E','F','Gb','G','Ab','A','Bb','B','C','Db','D'}; matthiasm@8: scale{5} = {'E','F','F#','G','G#','A','Bb','B','C','C#','D','D#'}; matthiasm@8: scale{6} = {'F','Gb','G','Ab','A','Bb','B','C','Db','D','Eb','E'}; matthiasm@8: scale{7} = {'Gb','G','Ab','A','Bb','Cb','C','Db','D','Eb','E','F'}; matthiasm@8: scale{8} = {'G','G#','A','Bb','B','C','C#','D','D#','E','F','F#'}; matthiasm@8: scale{9} = {'Ab','A','Bb','B','C','Db','D','Eb','E','F','Gb','G'}; matthiasm@8: scale{10} = {'A','Bb','B','C','C#','D','D#','E','F','F#','G','G#'}; matthiasm@8: scale{11} = {'Bb','B','C','Db','D','Eb','E','F','Gb','G','Ab','A'}; matthiasm@8: scale{12} = {'B','C','C#','D','D#','E','F','F#','G','G#','A','A#'}; matthiasm@8: scale{13} = {'Eb','E','F','Gb','G','Ab','A','Bb','B','C','Db','D'}; matthiasm@8: scale{14} = {'E','F','F#','G','G#','A','Bb','B','C','C#','D','D#'}; matthiasm@8: scale{15} = {'F','Gb','G','Ab','A','Bb','B','C','Db','D','Eb','E'}; matthiasm@8: scale{16} = {'Gb','G','Ab','A','Bb','Cb','C','Db','D','Eb','E','F'}; matthiasm@8: scale{17} = {'G','G#','A','Bb','B','C','C#','D','D#','E','F','F#'}; matthiasm@8: scale{18} = {'Ab','A','Bb','B','C','Db','D','Eb','E','F','Gb','G'}; matthiasm@8: scale{19} = {'A','Bb','B','C','C#','D','D#','E','F','F#','G','G#'}; matthiasm@8: scale{20} = {'Bb','B','C','Db','D','Eb','E','F','Gb','G','Ab','A'}; matthiasm@8: scale{21} = {'B','C','C#','D','D#','E','F','F#','G','G#','A','A#'}; matthiasm@8: scale{22} = {'C','C#','D','Eb','E','F','F#','G','Ab','A','Bb','B'}; matthiasm@8: scale{23} = {'Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B','C'}; matthiasm@8: scale{24} = {'D','D#','E','F','F#','G','G#','A','Bb','B','C','C#'}; matthiasm@8: outnote = scale{key}{mod(root - key,12)+1}; matthiasm@8: else matthiasm@8: outnote = ''; matthiasm@8: end matthiasm@8: case 'lily' matthiasm@8: if root ~= 13 matthiasm@8: scale{1} = {'c','cis','d','es','e','f','fis','g','as','a','bes','b'}; matthiasm@8: scale{2} = {'des','d','es','e','f','ges','g','as','a','bes','b','c'}; matthiasm@8: scale{3} = {'d','dis','e','f','fis','g','gis','a','bes','b','c','cis'}; matthiasm@8: scale{4} = {'es','e','f','ges','g','as','a','bes','b','c','des','d'}; matthiasm@8: scale{5} = {'e','f','fis','g','gis','a','bes','b','c','cis','d','dis'}; matthiasm@8: scale{6} = {'f','ges','g','as','a','bes','b','c','des','d','es','e'}; matthiasm@8: scale{7} = {'ges','g','as','a','bes','ces','c','des','d','es','e','f'}; matthiasm@8: scale{8} = {'g','gis','a','bes','b','c','cis','d','dis','e','f','fis'}; matthiasm@8: scale{9} = {'as','a','bes','b','c','des','d','es','e','f','ges','g'}; matthiasm@8: scale{10} = {'a','bes','b','c','cis','d','dis','e','f','fis','g','gis'}; matthiasm@8: scale{11} = {'bes','b','c','des','d','es','e','f','ges','g','as','a'}; matthiasm@8: scale{12} = {'b','c','cis','d','dis','e','f','fis','g','gis','a','ais'}; matthiasm@8: scale{13} = {'es','e','f','ges','g','as','a','bes','b','c','des','d'}; matthiasm@8: scale{14} = {'e','f','fis','g','gis','a','bes','b','c','cis','d','dis'}; matthiasm@8: scale{15} = {'f','ges','g','as','a','bes','b','c','des','d','es','e'}; matthiasm@8: scale{16} = {'ges','g','as','a','bes','ces','c','des','d','es','e','f'}; matthiasm@8: scale{17} = {'g','gis','a','bes','b','c','cis','d','dis','e','f','fis'}; matthiasm@8: scale{18} = {'as','a','bes','b','c','des','d','es','e','f','ges','g'}; matthiasm@8: scale{19} = {'a','bes','b','c','cis','d','dis','e','f','fis','g','gis'}; matthiasm@8: scale{20} = {'bes','b','c','des','d','es','e','f','ges','g','as','a'}; matthiasm@8: scale{21} = {'b','c','cis','d','dis','e','f','fis','g','gis','a','ais'}; matthiasm@8: scale{22} = {'c','cis','d','es','e','f','fis','g','as','a','bes','b'}; matthiasm@8: scale{23} = {'des','d','es','e','f','ges','g','as','a','bes','b','c'}; matthiasm@8: scale{24} = {'d','dis','e','f','fis','g','gis','a','bes','b','c','cis'}; matthiasm@8: outnote = scale{key}{mod(root - key,12)+1}; matthiasm@8: else matthiasm@8: outnote = 'r'; matthiasm@8: end matthiasm@8: end