spiffyscore
Diff
Not logged in

Differences From Artifact [3cbe823f2fbe19fa]:

To Artifact [967482cdda8a9c01]:


1 #!/usr/bin/env python 1 #!/usr/bin/env python 2 2 3 from __future__ import division 3 from __future__ import division 4 import os 4 import os > 5 import pdb 5 import random 6 import random 6 import sys 7 import sys 7 import time 8 import time 8 random.seed(time.time()) 9 random.seed(time.time()) 9 10 10 import parse 11 import parse 11 import topsort 12 import topsort 12 import yaml 13 import yaml > 14 > 15 from tree import * 13 16 14 def main(): 17 def main(): 15 key = "A" 18 key = "A" 16 bps = 60/60 19 bps = 60/60 17 tempo = 1/bps 20 tempo = 1/bps 18 max_duration = 1 21 max_duration = 1 19 22 20 composition = yaml.load(open("score.yaml")) 23 composition = yaml.load(open("score.yaml")) 21 24 22 max_t = 0 # max time encountered so far. Used for movement timing 25 max_t = 0 # max time encountered so far. Used for movement timing 23 progression = "chorus" 26 progression = "chorus" > 27 timeline = {} 24 28 25 for movement in progression.split(): 29 for movement in progression.split(): 26 for section in ["intro", "core", "outro"]: 30 for section in ["intro", "core", "outro"]: 27 if section in composition[movement].keys(): 31 if section in composition[movement].keys(): 28 try: 32 try: 29 render_order = topsort.topsort([[composition[movement][secti 33 render_order = topsort.topsort([[composition[movement][secti 30 except topsort.CycleError as ex: 34 except topsort.CycleError as ex: ................................................................................................................................................................................ 38 grammars = composition[movement][section][instrument]["gramm 42 grammars = composition[movement][section][instrument]["gramm 39 for grammar in grammars: 43 for grammar in grammars: 40 if isinstance(grammars[grammar], list): 44 if isinstance(grammars[grammar], list): 41 for option in range(len(grammar)): 45 for option in range(len(grammar)): 42 grammars[grammar][option] = parse.parse(grammars 46 grammars[grammar][option] = parse.parse(grammars 43 else: 47 else: 44 grammars[grammar] = parse.parse(grammars[grammar]) 48 grammars[grammar] = parse.parse(grammars[grammar]) 45 print instrument, movement, section | 49 print section, movement, instrument 46 print grammars 50 print grammars > 51 for grammar in grammars: > 52 t = Tree() > 53 pdb.set_trace() > 54 while reduce(lambda x, y: x+y, [node.time for node in t. > 55 pass > 56 timeline[movement][section][instrument] = Tree() 47 57 48 58 49 def generate_score_phrase(grammar, grammars): 59 def generate_score_phrase(grammar, grammars): 50 count_length = | 60 # count_length = 51 while count_length < 100000: | 61 # while count_length < 100000: 52 62 53 63 54 64 55 65 56 # for comp_name in progression.split(): 66 # for comp_name in progression.split(): 57 # comp_start_time = max_t 67 # comp_start_time = max_t 58 # for instr_name, instr in composition[comp_name].iteritems(): 68 # for instr_name, instr in composition[comp_name].iteritems():