
% map chord to mirex integer representation

function [val,success] = mxmap(chord, year)

success = 1;
errormessage = '';

[rootnote, shorthand,intervals, bassinterval, success, errormessage] = getchordinfo(chord);

if strcmp(rootnote,'N')

    val = 24;
    
else
    if success
        [val, success, errormessage] = note2pitchclass(rootnote);
    end

    if success
        switch year

            case 8
                if ~isempty(strfind(shorthand,'min'));
                    val = val+12;
                end
            case 9
                if ~(isempty(strfind(shorthand,'min')) & isempty(strfind(shorthand,'dim')) & isempty(strfind(shorthand,'sus2')));
                    val = val+12;
                end
            otherwise
                success = 0;
                errormessage = 'Error in mxmap: invalid year\n';

        end
    end
    
end