Give a list of possible substitutions for progression[substitute_index]. If depth > 0 the substitutions of each result will be recursively added as well. Example: >>> substitute(['I', 'IV', 'V', 'I'], 0) ['III', 'III7', 'VI', 'VI7', 'I7']
(progression, substitute_index, depth=0)
| 424 | |
| 425 | |
| 426 | def substitute(progression, substitute_index, depth=0): |
| 427 | """Give a list of possible substitutions for progression[substitute_index]. |
| 428 | |
| 429 | If depth > 0 the substitutions of each result will be recursively added |
| 430 | as well. |
| 431 | |
| 432 | Example: |
| 433 | >>> substitute(['I', 'IV', 'V', 'I'], 0) |
| 434 | ['III', 'III7', 'VI', 'VI7', 'I7'] |
| 435 | """ |
| 436 | res = [] |
| 437 | simple_substitutions = [ |
| 438 | ("I", "III"), |
| 439 | ("I", "VI"), |
| 440 | ("IV", "II"), |
| 441 | ("IV", "VI"), |
| 442 | ("V", "VII"), |
| 443 | ("V", "VIIdim7"), |
| 444 | ("V", "IIdim7"), |
| 445 | ("V", "IVdim7"), |
| 446 | ("V", "bVIIdim7"), |
| 447 | ] |
| 448 | p = progression[substitute_index] |
| 449 | (roman, acc, suff) = parse_string(p) |
| 450 | |
| 451 | # Do the simple harmonic substitutions |
| 452 | if suff == "" or suff == "7": |
| 453 | for subs in simple_substitutions: |
| 454 | r = None |
| 455 | if roman == subs[0]: |
| 456 | r = subs[1] |
| 457 | elif roman == subs[1]: |
| 458 | r = subs[0] |
| 459 | if r != None: |
| 460 | res.append(tuple_to_string((r, acc, ""))) |
| 461 | |
| 462 | # Add seventh or triad depending on r |
| 463 | if r[-1] != "7": |
| 464 | res.append(tuple_to_string((r, acc, "7"))) |
| 465 | else: |
| 466 | res.append(tuple_to_string((r[:-1], acc, ""))) |
| 467 | |
| 468 | if suff == "" or suff == "M" or suff == "m": |
| 469 | res.append(tuple_to_string((roman, acc, suff + "7"))) |
| 470 | |
| 471 | if suff == "m" or suff == "m7": |
| 472 | n = skip(roman, 2) |
| 473 | a = interval_diff(roman, n, 3) + acc |
| 474 | res.append(tuple_to_string((n, a, "M"))) |
| 475 | res.append(tuple_to_string((n, a, "M7"))) |
| 476 | |
| 477 | # Major to minor substitution |
| 478 | if suff == "M" or suff == "M7": |
| 479 | n = skip(roman, 5) |
| 480 | a = interval_diff(roman, n, 9) + acc |
| 481 | res.append(tuple_to_string((n, a, "m"))) |
| 482 | res.append(tuple_to_string((n, a, "m7"))) |
| 483 |
nothing calls this directly
no test coverage detected