spiffyscore

Check-in [601339a475]
Login
Overview
SHA1:601339a4752350846ea19719d96c178aa2f6b124
Date: 2011-10-20 19:21:19
User: brian
Comment:Fixed the issue with the score being cut short. Now the instruments are changing nodes without my say-so. Alos, they're not always printing complete nodes.
Timelines: family | ancestors | descendants | both | develop
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2011-10-20
19:56
[a9e60898b7] Program now chooses consistent nodes based on what's specified in the grammar. A couple other bugs are still present. (user: brian, tags: develop)
19:21
[601339a475] Fixed the issue with the score being cut short. Now the instruments are changing nodes without my say-so. Alos, they're not always printing complete nodes. (user: brian, tags: develop)
18:38
[8c559c112b] Merged the refactor branch into the main develop branch (user: brian, tags: develop)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified cfg.py from [6468589fde] to [47205bbb94].

   106    106           "sync_test": {
   107    107               "body": {
   108    108                   "lead_instr": {  # Instrument 'melody'
   109    109                       "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
   110    110                       "octave": 8,
   111    111                       "duration": 30,
   112    112                       "grammars": {  # Notes for this instrument to use in this piece
   113         -                        "u": ["D/4 D/4 D/4 D/4"],
   114         -                        "v": ["C/4 C/4 C/4 C/4"],
          113  +                        "u": ["D/4 D/4 D/4 D/4 (u)"],
          114  +                        "v": ["C/4 C/4 C/4 C/4 (v)"],
   115    115                       },
   116    116                   },
   117    117                   "follow_instr": {  # Instrument 'melody'
   118    118                       "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 1",
   119    119                       "sync": "lead_instr",
   120    120                       "octave": 8,
   121    121                       "duration": 30,
   122    122                       "grammars": {  # Notes for this instrument to use in this piece
   123         -                        "u": ["D/4 D/4 D/4 D/4"],
   124         -                        "v": ["C/4 C/4 C/4 C/4"],
          123  +                        "u": ["D/4 D/4 D/4 D/4 (u)"],
          124  +                        "v": ["C/4 C/4 C/4 C/4 (v)"],
   125    125                       },
   126    126                   },
   127    127               },
   128    128           },
   129    129       }
   130    130       print '''f1 0 512 10 1
   131    131   f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
................................................................................
   185    185                   if isinstance(score[item], tree.Tree):
   186    186                       score_index_to_replace = item
   187    187               if score_index_to_replace is None:
   188    188                   raise ValueError("No more nodes to fill in")
   189    189   
   190    190               time_remaining = max_time - score_len(score)
   191    191               new_phrase, syncs = choose_phrase(instr, syncs, score_len(score), time_remaining)
   192         -            score = score[:node_index-1] + new_phrase + score[node_index+1:]
          192  +            score = score[:score_index_to_replace-1] + new_phrase + score[score_index_to_replace+1:]
   193    193   
   194    194       except ValueError:
   195    195           return (score, syncs)
   196    196   
   197    197   
   198    198   def choose_phrase(instr, syncs, current_time, time_remaining):
   199    199       '''Filters grammars for ones that match the sync option, and phrases that fit the time remaining in the score'''
   200    200       time_filtered_grammars = {}
   201    201       for grammar in instr["grammars"]:
   202         -        time_filtered_grammars[grammar] = get_phrases_that_fit(instr["grammars"][grammar], time_remaining)
          202  +         fitting_phrases = get_phrases_that_fit(instr["grammars"][grammar], time_remaining)
          203  +         if len(fitting_phrases) > 0:
          204  +            time_filtered_grammars[grammar] = fitting_phrases
   203    205       if len(time_filtered_grammars.keys()) == 0:
   204    206           raise ValueError("No available grammars that will fit in the score")
   205    207   
   206    208       grammar = None
   207         -#    if instr["name"] == "follow_instr":
   208         -#        ipdb.set_trace()
   209    209       if instr["sync"] is not None:
   210    210           guiding_instr = instr["sync"]
   211    211           sync_node = get_sync_node_at_time(syncs[guiding_instr], current_time)
   212    212           if sync_node in time_filtered_grammars.keys():
   213    213               grammar = sync_node
   214    214       if grammar is None:
   215    215           grammar = random.choice(time_filtered_grammars.keys())