Пример #1
0
    def inversion_exhauster(triad, shorthand, tries, result):
        """Run tries every inversion and save the result."""
        intval1 = intervals.determine(triad[0], triad[1], True)
        intval2 = intervals.determine(triad[0], triad[2], True)

        def add_result(short):
            result.append((short, tries, triad[0]))

        intval = intval1 + intval2
        if intval == '25':
            add_result('sus2')
        elif intval == '3b7':
            add_result('dom7')  # changed from just '7'
        elif intval == '3b5':
            add_result('7b5')  # why not b5?
        elif intval == '35':
            add_result('M')
        elif intval == '3#5':
            add_result('aug')
        elif intval == '36':
            add_result('M6')
        elif intval == '37':
            add_result('M7')
        elif intval == 'b3b5':
            add_result('dim')
        elif intval == 'b35':
            add_result('m')
        elif intval == 'b36':
            add_result('m6')
        elif intval == 'b3b7':
            add_result('m7')
        elif intval == 'b37':
            add_result('m/M7')
        elif intval == '45':
            add_result('sus4')
        elif intval == '5b7':
            add_result('m7')
        elif intval == '57':
            add_result('M7')
        if tries != 3 and not no_inversions:
            return inversion_exhauster([triad[-1]] + triad[:-1], shorthand,
                                       tries + 1, result)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]] +
                               int_desc(r[1]))
            return res
Пример #2
0
    def inversion_exhauster(triad, shorthand, tries, result):
        """Run tries every inversion and save the result."""
        intval1 = intervals.determine(triad[0], triad[1], True)
        intval2 = intervals.determine(triad[0], triad[2], True)

        def add_result(short):
            result.append((short, tries, triad[0]))

        intval = intval1 + intval2
        if intval == '25':
            add_result('sus2')
        elif intval == '3b7':
            add_result('dom7')  # changed from just '7'
        elif intval == '3b5':
            add_result('7b5')  # why not b5?
        elif intval == '35':
            add_result('M')
        elif intval == '3#5':
            add_result('aug')
        elif intval == '36':
            add_result('M6')
        elif intval == '37':
            add_result('M7')
        elif intval == 'b3b5':
            add_result('dim')
        elif intval == 'b35':
            add_result('m')
        elif intval == 'b36':
            add_result('m6')
        elif intval == 'b3b7':
            add_result('m7')
        elif intval == 'b37':
            add_result('m/M7')
        elif intval == '45':
            add_result('sus4')
        elif intval == '5b7':
            add_result('m7')
        elif intval == '57':
            add_result('M7')
        if tries != 3 and not no_inversions:
            return inversion_exhauster([triad[-1]] + triad[:-1], shorthand,
                                       tries + 1, result)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]] +
                            int_desc(r[1]))
            return res
Пример #3
0
def determine(chord,
              shorthand=False,
              no_inversions=False,
              no_polychords=False):
    """Name a chord.

    This function can determine almost every chord, from a simple triad to a
    fourteen note polychord."""
    if chord == []:
        return []
    elif len(chord) == 1:
        return chord
    elif len(chord) == 2:
        return [intervals.determine(chord[0], chord[1])]
    elif len(chord) == 3:
        return determine_triad(chord, shorthand, no_inversions, no_polychords)
    elif len(chord) == 4:
        return determine_seventh(chord, shorthand, no_inversions,
                                 no_polychords)
    elif len(chord) == 5:
        return determine_extended_chord5(chord, shorthand, no_inversions,
                                         no_polychords)
    elif len(chord) == 6:
        return determine_extended_chord6(chord, shorthand, no_inversions,
                                         no_polychords)
    elif len(chord) == 7:
        return determine_extended_chord7(chord, shorthand, no_inversions,
                                         no_polychords)
    else:
        return determine_polychords(chord, shorthand)
Пример #4
0
    def inversion_exhauster(chord, shorthand, tries, result, polychords):
        """Recursive helper function."""
        # Determine polychords
        if tries == 1 and not no_polychords:
            polychords += determine_polychords(chord, shorthand)

        def add_result(short):
            result.append((short, tries, chord[0]))

        ch = determine_extended_chord6(chord[:6], True, True, True)
        intval6 = intervals.determine(chord[0], chord[6])
        for c in ch:
            c = c[len(chord[0]):]
            if c == '11':
                if intval6 == 'major sixth':
                    add_result('13')
            elif c == 'm11':
                if intval6 == 'major sixth':
                    add_result('m13')
            elif c == 'M11':
                if intval6 == 'major sixth':
                    add_result('M13')
        if tries != 6:
            return inversion_exhauster([chord[-1]] + chord[:-1], shorthand,
                                       tries + 1, result, polychords)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]] +
                               int_desc(r[1]))
            return res + polychords
Пример #5
0
def determine(chord, shorthand=False, no_inversions=False, no_polychords=False):
    """Name a chord.

    This function can determine almost every chord, from a simple triad to a
    fourteen note polychord."""
    if chord == []:
        return []
    elif len(chord) == 1:
        return chord
    elif len(chord) == 2:
        return [intervals.determine(chord[0], chord[1])]
    elif len(chord) == 3:
        return determine_triad(chord, shorthand, no_inversions, no_polychords)
    elif len(chord) == 4:
        return determine_seventh(chord, shorthand, no_inversions, no_polychords)
    elif len(chord) == 5:
        return determine_extended_chord5(chord, shorthand, no_inversions,
                no_polychords)
    elif len(chord) == 6:
        return determine_extended_chord6(chord, shorthand, no_inversions,
                no_polychords)
    elif len(chord) == 7:
        return determine_extended_chord7(chord, shorthand, no_inversions,
                no_polychords)
    else:
        return determine_polychords(chord, shorthand)
Пример #6
0
    def inversion_exhauster(chord, shorthand, tries, result, polychords):
        """Recursive helper function."""
        # Determine polychords
        if tries == 1 and not no_polychords:
            polychords += determine_polychords(chord, shorthand)

        def add_result(short):
            result.append((short, tries, chord[0]))

        ch = determine_extended_chord6(chord[:6], True, True, True)
        intval6 = intervals.determine(chord[0], chord[6])
        for c in ch:
            c = c[len(chord[0]):]
            if c == '11':
                if intval6 == 'major sixth':
                    add_result('13')
            elif c == 'm11':
                if intval6 == 'major sixth':
                    add_result('m13')
            elif c == 'M11':
                if intval6 == 'major sixth':
                    add_result('M13')
        if tries != 6:
            return inversion_exhauster([chord[-1]] + chord[:-1], shorthand,
                                       tries + 1, result, polychords)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]]
                                + int_desc(r[1]))
            return res + polychords
Пример #7
0
    def inversion_exhauster(chord, shorthand, tries, result, polychords):
        """Recursive helper function."""
        def add_result(short):
            result.append((short, tries, chord[0]))

        triads = determine_triad(chord[:3], True, True)
        sevenths = determine_seventh(chord[:4], True, True, True)

        # Determine polychords
        if tries == 1 and not no_polychords:
            polychords += determine_polychords(chord, shorthand)

        intval4 = intervals.determine(chord[0], chord[4])
        for seventh in sevenths:
            seventh = seventh[len(chord[0]):]
            if seventh == 'M7':
                if intval4 == 'major second':
                    add_result('M9')
            elif seventh == 'm7':
                if intval4 == 'major second':
                    add_result('m9')
                elif intval4 == 'perfect fourth':
                    add_result('m11')
            elif seventh == '7':
                if intval4 == 'major second':
                    add_result('9')
                elif intval4 == 'minor second':
                    add_result('7b9')
                elif intval4 == 'augmented second':
                    add_result('7#9')
                elif intval4 == 'minor third':
                    add_result('7b12')
                elif intval4 == 'augmented fourth':
                    add_result('7#11')
                elif intval4 == 'major sixth':
                    add_result('13')
            elif seventh == 'M6':
                if intval4 == 'major second':
                    add_result('6/9')
                elif intval4 == 'minor seventh':
                    add_result('6/7')
        if tries != 5 and not no_inversions:
            return inversion_exhauster([chord[-1]] + chord[:-1], shorthand,
                                       tries + 1, result, polychords)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]] +
                               int_desc(r[1]))
            return res + polychords
Пример #8
0
    def inversion_exhauster(chord, shorthand, tries, result, polychords):
        """Recursive helper function."""
        def add_result(short):
            result.append((short, tries, chord[0]))

        triads = determine_triad(chord[:3], True, True)
        sevenths = determine_seventh(chord[:4], True, True, True)

        # Determine polychords
        if tries == 1 and not no_polychords:
            polychords += determine_polychords(chord, shorthand)

        intval4 = intervals.determine(chord[0], chord[4])
        for seventh in sevenths:
            seventh = seventh[len(chord[0]):]
            if seventh == 'M7':
                if intval4 == 'major second':
                    add_result('M9')
            elif seventh == 'm7':
                if intval4 == 'major second':
                    add_result('m9')
                elif intval4 == 'perfect fourth':
                    add_result('m11')
            elif seventh == '7':
                if intval4 == 'major second':
                    add_result('9')
                elif intval4 == 'minor second':
                    add_result('7b9')
                elif intval4 == 'augmented second':
                    add_result('7#9')
                elif intval4 == 'minor third':
                    add_result('7b12')
                elif intval4 == 'augmented fourth':
                    add_result('7#11')
                elif intval4 == 'major sixth':
                    add_result('13')
            elif seventh == 'M6':
                if intval4 == 'major second':
                    add_result('6/9')
                elif intval4 == 'minor seventh':
                    add_result('6/7')
        if tries != 5 and not no_inversions:
            return inversion_exhauster([chord[-1]] + chord[:-1], shorthand,
                    tries + 1, result, polychords)
        else:
            res = []
            for r in result:
                if shorthand:
                    res.append(r[2] + r[0])
                else:
                    res.append(r[2] + chord_shorthand_meaning[r[0]]
                                + int_desc(r[1]))
            return res + polychords
Пример #9
0
    def inversion_exhauster(seventh, shorthand, tries, result, polychords):
        """Determine sevenths recursive functions."""
        # Check whether the first three notes of seventh are part of some triad.
        triads = determine_triad(seventh[:3], True, True)

        # Get the interval between the first and last note
        intval3 = intervals.determine(seventh[0], seventh[3])

        def add_result(short, poly=False):
            """Helper function."""
            result.append((short, tries, seventh[0], poly))

        # Recognizing polychords
        if tries == 1 and not no_polychords:
            polychords = polychords + determine_polychords(seventh, shorthand)

        # Recognizing sevenths
        for triad in triads:
            # Basic triads
            triad = triad[len(seventh[0]):]
            if triad == 'm':
                if intval3 == 'minor seventh':
                    add_result('m7')
                elif intval3 == 'major seventh':
                    add_result('m/M7')
                elif intval3 == 'major sixth':
                    add_result('m6')
            elif triad == 'M':
                if intval3 == 'major seventh':
                    add_result('M7')
                elif intval3 == 'minor seventh':
                    add_result('7')
                elif intval3 == 'major sixth':
                    add_result('M6')
            elif triad == 'dim':
                if intval3 == 'minor seventh':
                    add_result('m7b5')
                elif intval3 == 'diminished seventh':
                    add_result('dim7')
            elif triad == 'aug':
                if intval3 == 'minor seventh':
                    add_result('m7+')
                if intval3 == 'major seventh':
                    add_result('M7+')
            elif triad == 'sus4':
                if intval3 == 'minor seventh':
                    add_result('sus47')
                elif intval3 == 'minor second':
                    add_result('sus4b9')
            elif triad == 'm7':

                # Other
                if intval3 == 'perfect fourth':
                    add_result('11')
            elif triad == '7b5':
                if intval3 == 'minor seventh':
                    add_result('7b5')

        if tries != 4 and not no_inversion:
            return inversion_exhauster([seventh[-1]] + seventh[:-1], shorthand,
                                       tries + 1, result, polychords)
        else:
            # Return results
            res = []

            # Reset seventh
            seventh = [seventh[3]] + seventh[0:3]
            for x in result:
                if shorthand:
                    res.append(x[2] + x[0])
                else:
                    res.append(x[2] + chord_shorthand_meaning[x[0]] +
                               int_desc(x[1]))
            return res + polychords
Пример #10
0
    def inversion_exhauster(seventh, shorthand, tries, result, polychords):
        """Determine sevenths recursive functions."""
        # Check whether the first three notes of seventh are part of some triad.
        triads = determine_triad(seventh[:3], True, True)

        # Get the interval between the first and last note
        intval3 = intervals.determine(seventh[0], seventh[3])

        def add_result(short, poly=False):
            """Helper function."""
            result.append((short, tries, seventh[0], poly))

        # Recognizing polychords
        if tries == 1 and not no_polychords:
            polychords = polychords + determine_polychords(seventh, shorthand)

        # Recognizing sevenths
        for triad in triads:
            # Basic triads
            triad = triad[len(seventh[0]):]
            if triad == 'm':
                if intval3 == 'minor seventh':
                    add_result('m7')
                elif intval3 == 'major seventh':
                    add_result('m/M7')
                elif intval3 == 'major sixth':
                    add_result('m6')
            elif triad == 'M':
                if intval3 == 'major seventh':
                    add_result('M7')
                elif intval3 == 'minor seventh':
                    add_result('7')
                elif intval3 == 'major sixth':
                    add_result('M6')
            elif triad == 'dim':
                if intval3 == 'minor seventh':
                    add_result('m7b5')
                elif intval3 == 'diminished seventh':
                    add_result('dim7')
            elif triad == 'aug':
                if intval3 == 'minor seventh':
                    add_result('m7+')
                if intval3 == 'major seventh':
                    add_result('M7+')
            elif triad == 'sus4':
                if intval3 == 'minor seventh':
                    add_result('sus47')
                elif intval3 == 'minor second':
                    add_result('sus4b9')
            elif triad == 'm7':

            # Other
                if intval3 == 'perfect fourth':
                    add_result('11')
            elif triad == '7b5':
                if intval3 == 'minor seventh':
                    add_result('7b5')

        if tries != 4 and not no_inversion:
            return inversion_exhauster([seventh[-1]] + seventh[:-1], shorthand,
                    tries + 1, result, polychords)
        else:
            # Return results
            res = []

            # Reset seventh
            seventh = [seventh[3]] + seventh[0:3]
            for x in result:
                if shorthand:
                    res.append(x[2] + x[0])
                else:
                    res.append(x[2] + chord_shorthand_meaning[x[0]]
                                + int_desc(x[1]))
            return res + polychords