(see the original blog post if your reposting turns this code into goobley-gook...)
from music21 import corpus, meter, stream
score = corpus.parseWork('bach/bwv366')
ts = score.flat.getElementsByClass(meter.TimeSignature)
found = stream.Stream()
for part in score:
highestNoteNum = 0
for m in part.measures:
for n in m.notes:
if n.midi > highestNoteNum:
highestNoteNum = n.midi
highestNote = copy.deepcopy(n) # optional
# These two lines will keep the look of the original
# note values but make each note 1 4/4 measure long:
highestNote.quarterLength = 4
highestNote.lyric = '%s: M. %s: beat %s' % (
... which generates this snippet of notation...
...showing that for at least one piece, Bach was (probably accidentally) using the old medieval authentic, plagal, lower-octave-authentic, lower-octave-plagal, range designations!
This code is still needlessly complicated -- we're still working on simplifying it (notes will know their own clefs and beats; '3/4' will know that it should be divided into 1+1+1), but just a little taste of what's possible.
if n.name == 'C#':