Index: cfg.py ================================================================== --- cfg.py +++ cfg.py @@ -1,17 +1,20 @@ #!/usr/bin/env python from __future__ import division import os +import pdb import random import sys import time random.seed(time.time()) import parse import topsort import yaml + +from tree import * def main(): key = "A" bps = 60/60 tempo = 1/bps @@ -19,10 +22,11 @@ composition = yaml.load(open("score.yaml")) max_t = 0 # max time encountered so far. Used for movement timing progression = "chorus" + timeline = {} for movement in progression.split(): for section in ["intro", "core", "outro"]: if section in composition[movement].keys(): try: @@ -40,17 +44,23 @@ if isinstance(grammars[grammar], list): for option in range(len(grammar)): grammars[grammar][option] = parse.parse(grammars[grammar][option]) else: grammars[grammar] = parse.parse(grammars[grammar]) - print instrument, movement, section + print section, movement, instrument print grammars + for grammar in grammars: + t = Tree() + pdb.set_trace() + while reduce(lambda x, y: x+y, [node.time for node in t.traverse_depth_first()]) < instrument["max_duration"]: + pass + timeline[movement][section][instrument] = Tree() def generate_score_phrase(grammar, grammars): - count_length = - while count_length < 100000: +# count_length = +# while count_length < 100000: # for comp_name in progression.split():