INNER CODE UNIT · Python
measureStartTime
jisungk/deepjazz · grammar.py:135
measureStartTime = measure[0].offset - (measure[0].offset % 4)
measureStartOffset = measure[0].offset - measureStartTime
# Iterate over the notes and rests in measure, finding the grammar for each
# note in the measure and adding an abstract grammatical string for it.
fullGrammar = ""
prevNote = None # Store previous note. Need for interval.
numNonRests = 0 # Number of non-rest elements. Need for updating prevNote.
for ix, nr in enumerate(measure):
# Get the last chord. If no last chord, then (assuming chords is of length
# >0) shift first chord in chords to the beginning of the measure.
try:
lastChord = [n for n in chords if n.offset <= nr.offset][-1]
except IndexError:
chords[0].offset = measureStartTime
lastChord = [n for n in chords if n.offset <= nr.offset][-1]