INNER CODE UNIT · Python
__is_chord_tone
jisungk/deepjazz · grammar.py:50
def __is_chord_tone(lastChord, note):
return (note.name in (p.name for p in lastChord.pitches))
''' Helper function to generate a chord tone. '''
def __generate_chord_tone(lastChord):
lastChordNoteNames = [p.nameWithOctave for p in lastChord.pitches]
return note.Note(random.choice(lastChordNoteNames))
''' Helper function to generate a scale tone. '''
def __generate_scale_tone(lastChord):
# Derive major or minor scales (minor if 'other') based on the quality
# of the lastChord.
scaleType = scale.WeightedHexatonicBlues() # minor pentatonic
if lastChord.quality == 'major':
scaleType = scale.MajorScale()
# Can change later to deriveAll() for flexibility. If so then use list
# comprehension of form [x for a in b for x in a].
scales = scaleType.derive(lastChord) # use deriveAll() later for flexibility