Determine the type of seventh chord; return the results in a list, ordered on inversions. This function expects seventh to be a list of 4 notes. If shorthand is set to True, results will be returned in chord shorthand ('Cmin7', etc.); inversions will be dropped in that case. E
(
seventh, shorthand=False, no_inversion=False, no_polychords=False
)
| 1019 | |
| 1020 | |
| 1021 | def determine_seventh( |
| 1022 | seventh, shorthand=False, no_inversion=False, no_polychords=False |
| 1023 | ): |
| 1024 | """Determine the type of seventh chord; return the results in a list, |
| 1025 | ordered on inversions. |
| 1026 | |
| 1027 | This function expects seventh to be a list of 4 notes. |
| 1028 | |
| 1029 | If shorthand is set to True, results will be returned in chord shorthand |
| 1030 | ('Cmin7', etc.); inversions will be dropped in that case. |
| 1031 | |
| 1032 | Example: |
| 1033 | >>> determine_seventh(['C', 'E', 'G', 'B']) |
| 1034 | ['C major seventh', 'Em|CM'] |
| 1035 | """ |
| 1036 | if len(seventh) != 4: |
| 1037 | # warning raise exception: seventh chord is not a seventh chord |
| 1038 | return False |
| 1039 | |
| 1040 | def inversion_exhauster(seventh, shorthand, tries, result, polychords): |
| 1041 | """Determine sevenths recursive functions.""" |
| 1042 | # Check whether the first three notes of seventh are part of some triad. |
| 1043 | triads = determine_triad(seventh[:3], True, True) |
| 1044 | |
| 1045 | # Get the interval between the first and last note |
| 1046 | intval3 = intervals.determine(seventh[0], seventh[3]) |
| 1047 | |
| 1048 | def add_result(short, poly=False): |
| 1049 | """Helper function.""" |
| 1050 | result.append((short, tries, seventh[0], poly)) |
| 1051 | |
| 1052 | # Recognizing polychords |
| 1053 | if tries == 1 and not no_polychords: |
| 1054 | polychords = polychords + determine_polychords(seventh, shorthand) |
| 1055 | |
| 1056 | # Recognizing sevenths |
| 1057 | for triad in triads: |
| 1058 | # Basic triads |
| 1059 | triad = triad[len(seventh[0]) :] |
| 1060 | if triad == "m": |
| 1061 | if intval3 == "minor seventh": |
| 1062 | add_result("m7") |
| 1063 | elif intval3 == "major seventh": |
| 1064 | add_result("m/M7") |
| 1065 | elif intval3 == "major sixth": |
| 1066 | add_result("m6") |
| 1067 | elif triad == "M": |
| 1068 | if intval3 == "major seventh": |
| 1069 | add_result("M7") |
| 1070 | elif intval3 == "minor seventh": |
| 1071 | add_result("7") |
| 1072 | elif intval3 == "major sixth": |
| 1073 | add_result("M6") |
| 1074 | elif triad == "dim": |
| 1075 | if intval3 == "minor seventh": |
| 1076 | add_result("m7b5") |
| 1077 | elif intval3 == "diminished seventh": |
| 1078 | add_result("dim7") |
no test coverage detected