MCPcopy Create free account
hub / github.com/bspaans/python-mingus / inversion_exhauster

Function inversion_exhauster

mingus/core/chords.py:966–1016  ·  view source on GitHub ↗

Run tries every inversion and save the result.

(triad, shorthand, tries, result)

Source from the content-addressed store, hash-verified

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")
1003 elif intval == "57":
1004 add_result("M7")
1005 if tries != 3 and not no_inversions:
1006 return inversion_exhauster(
1007 [triad[-1]] + triad[:-1], shorthand, tries + 1, result
1008 )
1009 else:
1010 res = []
1011 for r in result:
1012 if shorthand:
1013 res.append(r[2] + r[0])
1014 else:
1015 res.append(r[2] + chord_shorthand_meaning[r[0]] + int_desc(r[1]))
1016 return res
1017
1018 return inversion_exhauster(triad, shorthand, 1, [])
1019

Callers 5

determine_triadFunction · 0.85
determine_seventhFunction · 0.85

Calls 8

add_resultFunction · 0.85
int_descFunction · 0.85
determine_triadFunction · 0.85
determine_polychordsFunction · 0.85
determine_seventhFunction · 0.85
determineMethod · 0.80

Tested by

no test coverage detected