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