Name the triad; return answers in a list. The third argument should not be given. If shorthand is True the answers will be in abbreviated form. This function can determine major, minor, diminished and suspended triads. Also knows about invertions. Examples: >>> determine_t
(triad, shorthand=False, no_inversions=False, placeholder=None)
| 943 | |
| 944 | |
| 945 | def determine_triad(triad, shorthand=False, no_inversions=False, placeholder=None): |
| 946 | """Name the triad; return answers in a list. |
| 947 | |
| 948 | The third argument should not be given. If shorthand is True the answers |
| 949 | will be in abbreviated form. |
| 950 | |
| 951 | This function can determine major, minor, diminished and suspended |
| 952 | triads. Also knows about invertions. |
| 953 | |
| 954 | Examples: |
| 955 | >>> determine_triad(['A', 'C', 'E']) |
| 956 | ['A minor triad', 'C major sixth, second inversion'] |
| 957 | >>> determine_triad(['C', 'E', 'A']) |
| 958 | ['C major sixth', 'A minor triad, first inversion'] |
| 959 | >>> determine_triad(['A', 'C', 'E'], True) |
| 960 | ['Am', 'CM6'] |
| 961 | """ |
| 962 | if len(triad) != 3: |
| 963 | # warning: raise exception: not a triad |
| 964 | return False |
| 965 | |
| 966 | def inversion_exhauster(triad, shorthand, tries, result): |
| 967 | """Run tries every inversion and save the result.""" |
| 968 | intval1 = intervals.determine(triad[0], triad[1], True) |
| 969 | intval2 = intervals.determine(triad[0], triad[2], True) |
| 970 | |
| 971 | def add_result(short): |
| 972 | result.append((short, tries, triad[0])) |
| 973 | |
| 974 | intval = intval1 + intval2 |
| 975 | if intval == "25": |
| 976 | add_result("sus2") |
| 977 | elif intval == "3b7": |
| 978 | add_result("dom7") # changed from just '7' |
| 979 | elif intval == "3b5": |
| 980 | add_result("7b5") # why not b5? |
| 981 | elif intval == "35": |
| 982 | add_result("M") |
| 983 | elif intval == "3#5": |
| 984 | add_result("aug") |
| 985 | elif intval == "36": |
| 986 | add_result("M6") |
| 987 | elif intval == "37": |
| 988 | add_result("M7") |
| 989 | elif intval == "b3b5": |
| 990 | add_result("dim") |
| 991 | elif intval == "b35": |
| 992 | add_result("m") |
| 993 | elif intval == "b36": |
| 994 | add_result("m6") |
| 995 | elif intval == "b3b7": |
| 996 | add_result("m7") |
| 997 | elif intval == "b37": |
| 998 | add_result("m/M7") |
| 999 | elif intval == "45": |
| 1000 | add_result("sus4") |
| 1001 | elif intval == "5b7": |
| 1002 | add_result("m7") |
no test coverage detected