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

Function substitute_minor_for_major

mingus/core/progressions.py:293–326  ·  view source on GitHub ↗

Substitute minor chords for its major equivalent. 'm' and 'm7' suffixes recognized, and ['II', 'III', 'VI'] if there is no suffix. Examples: >>> substitute_minor_for_major(['VI'], 0) ['I'] >>> substitute_minor_for_major(['Vm'], 0) ['bVIIM'] >>> substitute_minor_for_

(progression, substitute_index, ignore_suffix=False)

Source from the content-addressed store, hash-verified

291
292
293def substitute_minor_for_major(progression, substitute_index, ignore_suffix=False):
294 """Substitute minor chords for its major equivalent.
295
296 'm' and 'm7' suffixes recognized, and ['II', 'III', 'VI'] if there is no
297 suffix.
298
299 Examples:
300 >>> substitute_minor_for_major(['VI'], 0)
301 ['I']
302 >>> substitute_minor_for_major(['Vm'], 0)
303 ['bVIIM']
304 >>> substitute_minor_for_major(['VIm7'], 0)
305 ['IM7']
306 """
307 (roman, acc, suff) = parse_string(progression[substitute_index])
308 res = []
309
310 # Minor to major substitution
311 if (
312 suff == "m"
313 or suff == "m7"
314 or suff == ""
315 and roman in ["II", "III", "VI"]
316 or ignore_suffix
317 ):
318 n = skip(roman, 2)
319 a = interval_diff(roman, n, 3) + acc
320 if suff == "m" or ignore_suffix:
321 res.append(tuple_to_string((n, a, "M")))
322 elif suff == "m7" or ignore_suffix:
323 res.append(tuple_to_string((n, a, "M7")))
324 elif suff == "" or ignore_suffix:
325 res.append(tuple_to_string((n, a, "")))
326 return res
327
328
329def substitute_major_for_minor(progression, substitute_index, ignore_suffix=False):

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