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

Function substitute_major_for_minor

mingus/core/progressions.py:329–360  ·  view source on GitHub ↗

Substitute major chords for their minor equivalent. 'M' and 'M7' suffixes recognized, and ['I', 'IV', 'V'] if there is no suffix. Examples: >>> substitute_major_for_minor(['I'], 0) ['VI'] >>> substitute_major_for_minor(['VM7'], 0) ['IIIm7']

(progression, substitute_index, ignore_suffix=False)

Source from the content-addressed store, hash-verified

327
328
329def substitute_major_for_minor(progression, substitute_index, ignore_suffix=False):
330 """Substitute major chords for their minor equivalent.
331
332 'M' and 'M7' suffixes recognized, and ['I', 'IV', 'V'] if there is no
333 suffix.
334
335 Examples:
336 >>> substitute_major_for_minor(['I'], 0)
337 ['VI']
338 >>> substitute_major_for_minor(['VM7'], 0)
339 ['IIIm7']
340 """
341 (roman, acc, suff) = parse_string(progression[substitute_index])
342 res = []
343
344 # Major to minor substitution
345 if (
346 suff == "M"
347 or suff == "M7"
348 or suff == ""
349 and roman in ["I", "IV", "V"]
350 or ignore_suffix
351 ):
352 n = skip(roman, 5)
353 a = interval_diff(roman, n, 9) + acc
354 if suff == "M" or ignore_suffix:
355 res.append(tuple_to_string((n, a, "m")))
356 elif suff == "M7" or ignore_suffix:
357 res.append(tuple_to_string((n, a, "m7")))
358 elif suff == "" or ignore_suffix:
359 res.append(tuple_to_string((n, a, "")))
360 return res
361
362
363def substitute_diminished_for_diminished(

Callers

nothing calls this directly

Calls 4

parse_stringFunction · 0.85
skipFunction · 0.85
interval_diffFunction · 0.85
tuple_to_stringFunction · 0.85

Tested by

no test coverage detected