Skip to content

Instantly share code, notes, and snippets.

@eamonnbell
Created May 26, 2013 12:41
Show Gist options
  • Save eamonnbell/5652681 to your computer and use it in GitHub Desktop.
Save eamonnbell/5652681 to your computer and use it in GitHub Desktop.
Show the results of all possible selections of up to MAX_OPS NRTs acting on D minor. Very slow after MAX_OPS = 4.
import music21
import itertools
MAX_OPS = 6
c = music21.chord.Chord('D4 F4 A4')
display = music21.stream.Stream()
LRPcombs = music21.analysis.neoRiemannian.LRP_combinations
for i in range(MAX_OPS +1):
for chain in itertools.product('LRP', repeat=i):
c_working = c
measure = music21.stream.Measure()
measure.repeatAppend(c, 1)
c_working = LRPcombs(c, "".join(chain))
c_working.lyric = "".join(chain)
measure.repeatAppend(c_working, 1)
display.append(measure)
display.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment