Index: parse.py ================================================================== --- parse.py +++ parse.py @@ -2,30 +2,30 @@ import tree from ply import lex, yacc class Note(): - def __init__(self, value, duration=.25, octave=8): + def __init__(self, value, duration=1, octave=8): self.value = value self.duration = duration self.octave = octave self.accidental = None def __repr__(self): return "Note %s %s %s" % (self.value, self.duration, self.octave) class Chord(): - def __init__(self, value, duration=.25, chord_type="major", octave=5): + def __init__(self, value, duration=1, chord_type="major", octave=5): self.value = value self.duration = duration self.chord_type = chord_type self.octave = octave def __repr__(self): return "Chord %s %s %s" % (self.value, self.duration, self.chord_type, self.octave) class Rest(): - def __init__(self, duration=.25): + def __init__(self, duration=1): self.duration = duration def __repr__(self): return "Rest node %s" % self.duration @@ -110,11 +110,11 @@ def p_chord_length(p): ''' chord : chord NOTE_LENGTH ''' new_note = p[1] - new_note.duration = 4*p[2] + new_note.duration = p[2] p[0] = new_note def p_chord(p): '''chord : QUOTE pitch QUOTE @@ -150,11 +150,11 @@ ''' rest : REST | REST NOTE_LENGTH ''' p[0] = Rest() if len(p) > 2: - p[0].duration = 4*p[2] + p[0].duration = p[2] def p_node(p): '''node : NODE ''' p[0] = tree.Tree(p[1].strip("(").strip(")")) Index: test.sco ================================================================== --- test.sco +++ test.sco @@ -7,73 +7,28 @@ i2 0.250000 0.250000 7000 8.09 2 i2 0.500000 0.250000 7000 8.02 2 i2 0.750000 0.250000 7000 8.07 2 i2 1.000000 0.250000 7000 8.05 2 i2 1.250000 0.250000 7000 8.05 2 -i2 1.500000 0.250000 7000 8.00 2 -i2 1.750000 0.500000 7000 8.07 2 -i2 2.250000 0.500000 7000 8.07 2 -i2 2.750000 0.500000 7000 8.07 2 -i2 3.250000 0.250000 7000 8.00 2 -i2 3.500000 0.250000 7000 7.11 2 -i2 3.750000 0.250000 7000 9.05 2 -i2 4.000000 0.250000 7000 8.00 2 -i2 4.250000 0.250000 7000 8.05 2 -i2 4.500000 0.250000 7000 8.00 2 -i2 4.750000 0.250000 7000 8.11 2 -i2 5.000000 0.250000 7000 8.04 2 -i2 5.250000 0.250000 7000 8.09 2 -i2 5.500000 0.250000 7000 8.02 2 -i2 5.750000 0.250000 7000 8.07 2 -i2 6.000000 0.250000 7000 8.05 2 -i2 6.250000 0.250000 7000 8.05 2 -i2 6.500000 2.000000 7000 8.11 2 -i2 8.500000 0.250000 7000 8.02 2 -i2 8.750000 0.250000 7000 8.02 2 -i2 9.000000 0.500000 7000 8.07 2 -i2 9.500000 0.500000 7000 8.09 2 -i2 10.000000 0.250000 7000 8.02 2 -i2 10.250000 0.250000 7000 8.00 2 -i2 10.500000 0.250000 7000 8.00 2 -i2 10.750000 0.250000 7000 8.00 2 -i2 11.000000 0.250000 7000 8.00 2 -i2 11.250000 0.500000 7000 8.05 2 -i2 11.750000 0.500000 7000 8.05 2 -i2 12.250000 0.250000 7000 8.00 2 -i2 12.500000 0.250000 7000 8.00 2 -i2 12.750000 0.250000 7000 8.00 2 -i2 13.000000 0.250000 7000 8.00 2 -i2 13.250000 0.500000 7000 8.05 2 -i2 13.750000 0.500000 7000 8.05 2 -i2 14.250000 0.250000 7000 8.00 2 -i2 14.500000 0.250000 7000 8.00 2 -i2 14.750000 0.250000 7000 8.00 2 -i2 15.000000 0.250000 7000 8.00 2 -i2 15.250000 0.500000 7000 8.05 2 -i2 15.750000 0.500000 7000 8.05 2 -i2 16.250000 0.500000 7000 8.05 2 -i2 8.500000 0.250000 7000 8.02 2 -i2 8.750000 0.250000 7000 8.02 2 -i2 9.000000 0.500000 7000 8.07 2 -i2 9.500000 0.500000 7000 8.09 2 -i2 10.000000 0.250000 7000 8.02 2 -i2 10.250000 0.250000 7000 8.02 2 -i2 10.500000 0.250000 7000 8.02 2 -i2 10.750000 0.500000 7000 8.07 2 -i2 11.250000 0.500000 7000 8.09 2 -i2 11.750000 0.250000 7000 8.02 2 -i2 12.000000 0.250000 7000 8.02 2 -i2 12.250000 0.250000 7000 8.02 2 -i2 12.500000 0.500000 7000 8.07 2 -i2 13.000000 0.500000 7000 8.09 2 -i2 13.500000 0.250000 7000 8.02 2 -i2 13.750000 0.250000 7000 8.02 2 -i2 14.000000 0.250000 7000 8.02 2 -i2 14.250000 0.500000 7000 8.07 2 -i2 14.750000 0.500000 7000 8.09 2 -i2 15.250000 0.250000 7000 8.02 2 -i2 15.500000 0.250000 7000 8.02 2 -i2 15.750000 0.250000 7000 8.02 2 -i2 16.000000 0.500000 7000 8.07 2 -i2 16.500000 0.500000 7000 8.09 2 -i2 17.000000 0.250000 7000 8.02 2 -i2 17.250000 0.250000 7000 8.02 2 +i2 1.500000 2.000000 7000 8.11 2 +i2 3.500000 1.000000 7000 8.02 2 +i2 4.500000 1.000000 7000 8.02 2 +i2 5.500000 0.500000 7000 8.07 2 +i2 6.000000 0.500000 7000 8.09 2 +i2 6.500000 1.000000 7000 8.02 2 +i2 7.500000 1.000000 7000 8.02 2 +i2 8.500000 1.000000 7000 8.02 2 +i2 9.500000 0.500000 7000 8.07 2 +i2 10.000000 0.500000 7000 8.09 2 +i2 10.500000 1.000000 7000 8.02 2 +i2 11.500000 1.000000 7000 8.02 2 +i2 3.500000 1.000000 7000 8.02 2 +i2 4.500000 1.000000 7000 8.02 2 +i2 5.500000 0.500000 7000 8.07 2 +i2 6.000000 0.500000 7000 8.09 2 +i2 6.500000 1.000000 7000 8.02 2 +i2 7.500000 1.000000 7000 8.02 2 +i2 8.500000 1.000000 7000 8.02 2 +i2 9.500000 0.500000 7000 8.07 2 +i2 10.000000 0.500000 7000 8.09 2 +i2 10.500000 1.000000 7000 8.02 2 +i2 11.500000 1.000000 7000 8.02 2