Overview
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 |
Files: | files | file ages | folders |
SHA1: |
601339a4752350846ea19719d96c178a |
User & Date: | brian on 2011-10-20 19:21:19 |
Other Links: | branch diff | manifest | tags |
Context
2011-10-20
| ||
19:56 | Program now chooses consistent nodes based on what's specified in the grammar. A couple other bugs are still present. check-in: a9e60898b7 user: brian tags: develop | |
19:21 | 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. check-in: 601339a475 user: brian tags: develop | |
18:38 | Merged the refactor branch into the main develop branch check-in: 8c559c112b user: brian tags: develop | |
Changes
Modified cfg.py from [6468589fde] to [47205bbb94].
︙ | ︙ | |||
106 107 108 109 110 111 112 | "sync_test": { "body": { "lead_instr": { # Instrument 'melody' "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6", "octave": 8, "duration": 30, "grammars": { # Notes for this instrument to use in this piece | | | | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | "sync_test": { "body": { "lead_instr": { # Instrument 'melody' "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6", "octave": 8, "duration": 30, "grammars": { # Notes for this instrument to use in this piece "u": ["D/4 D/4 D/4 D/4 (u)"], "v": ["C/4 C/4 C/4 C/4 (v)"], }, }, "follow_instr": { # Instrument 'melody' "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 1", "sync": "lead_instr", "octave": 8, "duration": 30, "grammars": { # Notes for this instrument to use in this piece "u": ["D/4 D/4 D/4 D/4 (u)"], "v": ["C/4 C/4 C/4 C/4 (v)"], }, }, }, }, } print '''f1 0 512 10 1 f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08 |
︙ | ︙ | |||
185 186 187 188 189 190 191 | if isinstance(score[item], tree.Tree): score_index_to_replace = item if score_index_to_replace is None: raise ValueError("No more nodes to fill in") time_remaining = max_time - score_len(score) new_phrase, syncs = choose_phrase(instr, syncs, score_len(score), time_remaining) | | | > > < < | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | if isinstance(score[item], tree.Tree): score_index_to_replace = item if score_index_to_replace is None: raise ValueError("No more nodes to fill in") time_remaining = max_time - score_len(score) new_phrase, syncs = choose_phrase(instr, syncs, score_len(score), time_remaining) score = score[:score_index_to_replace-1] + new_phrase + score[score_index_to_replace+1:] except ValueError: return (score, syncs) def choose_phrase(instr, syncs, current_time, time_remaining): '''Filters grammars for ones that match the sync option, and phrases that fit the time remaining in the score''' time_filtered_grammars = {} for grammar in instr["grammars"]: fitting_phrases = get_phrases_that_fit(instr["grammars"][grammar], time_remaining) if len(fitting_phrases) > 0: time_filtered_grammars[grammar] = fitting_phrases if len(time_filtered_grammars.keys()) == 0: raise ValueError("No available grammars that will fit in the score") grammar = None if instr["sync"] is not None: guiding_instr = instr["sync"] sync_node = get_sync_node_at_time(syncs[guiding_instr], current_time) if sync_node in time_filtered_grammars.keys(): grammar = sync_node if grammar is None: grammar = random.choice(time_filtered_grammars.keys()) |
︙ | ︙ |