104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
p[0] = new_note
def p_chord(p):
'''chord : BRACKET note BRACKET
| BRACKET note CHORD_TYPE BRACKET
'''
root_note = p[2].value
chorded_notes = []
for offset in [0, 4, 7]:
chorded_notes.append(Note(root_note+offset, octave=p[2].octave))
p[0] = Chord(notes=chorded_notes)
def p_note_syncopate(p):
''' note : note SYNCOPATE
'''
note.syncopate = p[2]
|
|
>
|
|
|
|
>
>
>
|
>
|
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
p[0] = new_note
def p_chord(p):
'''chord : BRACKET note BRACKET
| BRACKET note CHORD_TYPE BRACKET
'''
if len(p) > 3:
chorded_notes = []
root_note = p[2].value
for offset in [0, 4, 7]:
chorded_notes.append(Note(root_note+offset, octave=p[2].octave))
chord = Chord(notes=chorded_notes)
else: # This won'k work until the grammar is modified to rocognise multiple notes botween brackets
chord = p[1:-2]
p[0] = chord
def p_note_syncopate(p):
''' note : note SYNCOPATE
'''
note.syncopate = p[2]
|