spiffyscore

Check-in [60bf1cfb19]
Login
Overview
Comment:Made some changes to the parser. Don't remember what.
Timelines: family | ancestors | descendants | both | tree
Files: files | file ages | folders
SHA1: 60bf1cfb19f81e66ee82e17cb8977cdd6a30fc0e
User & Date: brian on 2011-06-12 20:32:59
Other Links: branch diff | manifest | tags
Context
2011-09-13
18:28
[Broken] Trying to get the tree structuse working Closed-Leaf check-in: 299ddec90e user: brian tags: tree
2011-06-12
20:32
Made some changes to the parser. Don't remember what. check-in: 60bf1cfb19 user: brian tags: tree
20:31
Create new branch named "tree" check-in: 2beaf09ad7 user: brian tags: tree
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified cfg.py from [e9b556b4f3] to [3cbe823f2f].

    28     28                   try:
    29     29                       render_order = topsort.topsort([[composition[movement][section][instrument]["sync"], instrument] if "sync" in composition[movement][section][instrument].keys() else [None, instrument] for instrument in composition[movement][section]])
    30     30                   except topsort.CycleError as ex:
    31     31                       print "Your instruments are synced in a circle! This makes no sense!"
    32     32                       print movement, section
    33     33                       print ex
    34     34                       sys.exit(1)
           35  +                while None in render_order:
           36  +                    render_order.remove(None)
           37  +                for instrument in render_order:
           38  +                    grammars = composition[movement][section][instrument]["grammars"]
           39  +                    for grammar in grammars:
           40  +                        if isinstance(grammars[grammar], list):
           41  +                            for option in range(len(grammar)):
           42  +                                grammars[grammar][option] = parse.parse(grammars[grammar][option])
           43  +                        else:
           44  +                            grammars[grammar] = parse.parse(grammars[grammar])
           45  +                    print instrument, movement, section
           46  +                    print grammars
           47  +
           48  +
           49  +def generate_score_phrase(grammar, grammars):
           50  +    count_length = 
           51  +    while count_length < 100000:
           52  +    
           53  +
    35     54                   
    36     55   
    37     56   #    for comp_name in progression.split():
    38     57   #        comp_start_time = max_t
    39     58   #        for instr_name, instr in composition[comp_name].iteritems():
    40     59   #            generated_score = generate_score(instr["score"], instr["grammars"])  # Fill in the scores by generating them based on the grammars
    41     60   ##            print generated_score

Modified parse.py from [3ec57c3fbe] to [c06717e335].

    13     13   class Chord():
    14     14       def __init__(self, value, duration=.5, chord_type="major", octave=5):
    15     15           self.value = value
    16     16           self.duration = duration
    17     17           self.chord_type = chord_type
    18     18           self.octave = octave
    19     19       def __repr__(self):
    20         -        return "Chord %s %s %s" % (self.value, self.duration, self.chord_type, self.octave)
           20  +        return "Chord %s %d %s %s" % (self.value, self.duration, self.chord_type, self.octave)
    21     21   
    22     22   class Rest():
    23     23       def __init__(self, duration=.25):
    24     24           self.duration = duration
    25     25       def __repr__(self):
    26     26           return "Rest node %s" % self.duration
    27     27   
................................................................................
    33     33           "BASENOTE",
    34     34           "ACCIDENTAL",
    35     35           "REST",
    36     36           "OCTAVE",
    37     37           "CHORD_TYPE",
    38     38           "PAREN",
    39     39           "SYNCOPATE",
           40  +        "NODE",
    40     41       )
    41     42   
    42     43       t_ignore = " |"
    43     44   
    44         -    #t_BASENOTE = r"[A-Ga-g]"
    45     45       t_BASENOTE = r"I+V?|VI*|i+v?|vi*"
    46     46       t_ACCIDENTAL = r"\^{1,2}|_{1,2}|="
    47     47       t_REST = r"z"
    48     48       t_OCTAVE = r"'+|,+"
    49         -    t_CHORD_TYPE = r"m|7|m7|0|o|\+|mb5|sus|sus4|maj7|mmaj7|7sus4|dim|dim7|7b5|m7b5|6|b6|m6|mb6|46|maj9|9|add9|7b9|m9"
           49  +    t_CHORD_TYPE = r"m|7|m7|0|o|mb5|sus|sus4|maj7|mmaj7|7sus4|dim|dim7|7b5|m7b5|6|b6|m6|mb6|46|maj9|9|add9|7b9|m9"
    50     50       t_PAREN = "\(|\)"
    51     51       t_SYNCOPATE = "\+|-"
           52  +#    t_NODE = "\w*(?!(([Vv][Ii]{0,3})|([Ii][Vv]?)))\w+"
           53  +    t_NODE = "\S+"
    52     54   
    53     55       def t_NOTE_LENGTH(t):
    54     56           r"/?\d+"
    55     57           multiplier = float(t.value.strip("/"))
    56     58           if t.value.startswith("/"):
    57     59               multiplier = 1/multiplier
    58     60           t.value = multiplier
................................................................................
    67     69   
    68     70       # Parse (yacc)
    69     71   
    70     72       def p_note_list(p):
    71     73           '''score : score note
    72     74                    | score chord
    73     75                    | score rest
           76  +                 | score node
    74     77           '''
    75     78           p[0] = p[1] + [p[2]]
    76     79   
    77     80       def p_score(p):
    78     81           '''score : note
    79     82                    | chord
    80     83                    | rest
    81     84           '''
    82     85           p[0] = [p[1]]
    83     86   
           87  +
           88  +    def p_node(p):
           89  +        '''node : NODE
           90  +        '''
           91  +        p[0] = p[1]
           92  +
    84     93   
    85     94       def p_chord_length(p):
    86     95           ''' chord : chord NOTE_LENGTH
    87     96           '''
    88     97           new_note = p[1]
    89     98           new_note.duration = p[2]
    90     99           p[0] = new_note
................................................................................
   101    110       def p_chord(p):
   102    111           '''chord : PAREN note PAREN
   103    112                    | PAREN note CHORD_TYPE PAREN
   104    113           '''
   105    114           pitch = p[2].value
   106    115           pitch = pitch.upper()
   107    116           p[0] = Chord(value=pitch, octave=default_octave)
   108         -        if len(p) > 3:
          117  +        if len(p) > 4:
   109    118               p[0].chord_type = p[3]
   110    119   
   111    120   
   112    121       def p_note_syncopate(p):
   113    122           ''' note : note SYNCOPATE
   114    123           '''
   115         -        note.syncopate = p[2]
          124  +        p[1].syncopate = p[2]
          125  +        p[0] = p[1]
   116    126   
   117    127   
   118    128       def p_accidental(p):
   119    129           '''note : ACCIDENTAL note
   120    130           '''
   121    131           p[2].accidental = p[1]
   122    132           p[0] = p[2]