INNER CODE UNIT · Python
lastChord
jisungk/deepjazz · grammar.py:148
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]
# FIRST, get type of note, e.g. R for Rest, C for Chord, etc.
# Dealing with solo notes here. If unexpected chord: still call 'C'.
elementType = ' '
# R: First, check if it's a rest. Clearly a rest --> only one possibility.
if isinstance(nr, note.Rest):
elementType = 'R'
# C: Next, check to see if note pitch is in the last chord.
elif nr.name in lastChord.pitchNames or isinstance(nr, chord.Chord):
elementType = 'C'
# L: (Complement tone) Skip this for now.
# S: Check if it's a scale tone.
elif __is_scale_tone(lastChord, nr):
elementType = 'S'