spiffyscore

Diff
Login

Differences From Artifact [3a88b8ab43]:

To Artifact [40393160ad]:


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
126
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141
class Rest():
    def __init__(self, duration=.25):
        self.duration = duration
    def __repr__(self):
        return "Rest node %s" % self.duration


def parse(score):
    # Tokenize (lex)
    tokens = (
        "NOTE_LENGTH",
        "BASENOTE",
        "ACCIDENTAL",
        "REST",
        "OCTAVE",
................................................................................
        p[2].accidental = p[1]
        p[0] = p[2]

    def p_octave(p):
        '''pitch : pitch OCTAVE
        '''
        count = len(p[2])
        increment_or_decrement = 1 if p[2][0] == "," else -1

        octave = 8 + (count * increment_or_decrement)
        p[1].octave = octave
        p[0] = p[1]

    def p_pitch(p):
        '''pitch : BASENOTE
        '''
        p[0] = Note(p[1])







|







 







|
>
|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
class Rest():
    def __init__(self, duration=.25):
        self.duration = duration
    def __repr__(self):
        return "Rest node %s" % self.duration


def parse(score, default_octave=8):
    # Tokenize (lex)
    tokens = (
        "NOTE_LENGTH",
        "BASENOTE",
        "ACCIDENTAL",
        "REST",
        "OCTAVE",
................................................................................
        p[2].accidental = p[1]
        p[0] = p[2]

    def p_octave(p):
        '''pitch : pitch OCTAVE
        '''
        count = len(p[2])
        increment_or_decrement = 1 if p[2][0] == "'" else -1
        print "octave=", default_octave
        octave = default_octave + (count * increment_or_decrement)
        p[1].octave = octave
        p[0] = p[1]

    def p_pitch(p):
        '''pitch : BASENOTE
        '''
        p[0] = Note(p[1])