Determine the polychords in chord. This function can handle anything from polychords based on two triads to 6 note extended chords.
(chord, shorthand=False)
| 1297 | |
| 1298 | |
| 1299 | def determine_polychords(chord, shorthand=False): |
| 1300 | """Determine the polychords in chord. |
| 1301 | |
| 1302 | This function can handle anything from polychords based on two triads to |
| 1303 | 6 note extended chords. |
| 1304 | """ |
| 1305 | polychords = [] |
| 1306 | function_list = [ |
| 1307 | determine_triad, |
| 1308 | determine_seventh, |
| 1309 | determine_extended_chord5, |
| 1310 | determine_extended_chord6, |
| 1311 | determine_extended_chord7, |
| 1312 | ] |
| 1313 | |
| 1314 | # Range tracking. |
| 1315 | if len(chord) <= 3: |
| 1316 | return [] |
| 1317 | elif len(chord) > 14: |
| 1318 | return [] |
| 1319 | elif len(chord) - 3 <= 5: |
| 1320 | function_nr = list(range(0, len(chord) - 3)) |
| 1321 | else: |
| 1322 | function_nr = list(range(0, 5)) |
| 1323 | for f in function_nr: |
| 1324 | for f2 in function_nr: |
| 1325 | # The clever part: Try the function_list[f] on the len(chord) - (3 + |
| 1326 | # f) last notes of the chord. Then try the function_list[f2] on the |
| 1327 | # f2 + 3 first notes of the chord. Thus, trying all possible |
| 1328 | # combinations. |
| 1329 | for chord1 in function_list[f]( |
| 1330 | chord[len(chord) - (3 + f) :], True, True, True |
| 1331 | ): |
| 1332 | for chord2 in function_list[f2](chord[: f2 + 3], True, True, True): |
| 1333 | polychords.append("%s|%s" % (chord1, chord2)) |
| 1334 | if shorthand: |
| 1335 | for p in polychords: |
| 1336 | p = p + " polychord" |
| 1337 | return polychords |
| 1338 | |
| 1339 | |
| 1340 | # A dictionairy that can be used to present chord abbreviations. This |
no outgoing calls
no test coverage detected