12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
key = "A"
bps = 60/60
tempo = 1/bps
max_duration = 1
composition = {
"a": { # Movement block 'a' for reuse throughout the piece
"melody": { # Instrument 'melody'
"score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
"octave": 8,
"duration": 40,
"grammars": { # Notes for this instrument to use in this piece
"u": ["I V/2 V/2 V/2 I VII, IV' x u", "I IV w w", "I VII IV u u"],
"w": ['VII I IV V VI u', 'w w'],
"x": ['VI/4 III/4 II/4 I/4 w', 'x x'],
},
"score": "u",
},
"rhythm": {
"score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
"octave": 7,
"duration": 50,
"grammars": {
"u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
"w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
"x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
"y": ['"I" "vi"2 "IV" "V" y y u'],
},
"score": "u x u y x w u",
},
# "bass": {
# "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
# "octave": 5,
# "grammars": { # Notes for this instrument to use in this piece
# "u": ['"I" "V" "vi" "iii" "IV" "I" "IV" "V" u u' , "e"],
# "e": [""],
# },
# "score": "u u u u u",
# },
},
"b": { # Movement block 'a' for reuse throughout the piece
"melody": { # Instrument 'melody'
"score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
"octave": 8,
"duration": 20,
"grammars": { # Notes for this instrument to use in this piece
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
>
|
|
>
|
|
<
|
|
|
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
key = "A"
bps = 60/60
tempo = 1/bps
max_duration = 1
composition = {
"a": { # Movement block 'a' for reuse throughout the piece
# "melody": { # Instrument 'melody'
# "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
# "octave": 8,
# "duration": 40,
# "grammars": { # Notes for this instrument to use in this piece
# "u": ["I V/2 V/2 V/2 I VII, IV' x u", "I IV w w", "I VII IV u u"],
# "w": ['VII I IV V VI u', 'w w'],
# "x": ['VI/4 III/4 II/4 I/4 w', 'x x'],
# },
# "score": "u",
# },
# "rhythm": {
# "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
# "octave": 7,
# "duration": 50,
# "grammars": {
# "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
# "w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
# "x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
# "y": ['"I" "vi"2 "IV" "V" y y u'],
# },
# "score": "u x u y x w u",
# },
"timbre": {
"score_line": "i3 %(time)f %(duration)f 5000 %(octave)d.%(note)s 2 3 5 3",
"octave": 5,
"duration": 40,
"grammars": { # Notes for this instrument to use in this piece
"u": ['I2 I2 V VI I/2 IV/2 "V"2 "I"2']
},
"score": "u u u u u",
},
},
"b": { # Movement block 'a' for reuse throughout the piece
"melody": { # Instrument 'melody'
"score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
"octave": 8,
"duration": 20,
"grammars": { # Notes for this instrument to use in this piece
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
break
max_t = t if t > max_t else max_t
composition[comp_name][instr_name]["score"] = score
# Must be done after all note times keyed in, else you can't coordinate melodies with the rhythm chords
print '''f1 0 512 10 1
f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
'''
for comp_name in progression.split():
for instr_name, instr in composition[comp_name].iteritems():
composition[comp_name][instr_name]["score"] = transliterate_score(composition[comp_name][instr_name]["score"], key)
# print "\nMovement %s instrument %s" % (comp_name, instr_name)
# print composition[comp_name][instr_name]["score"]
final_score = generate_csound_score(composition[comp_name][instr_name]["score"], composition[comp_name][instr_name]["score_line"])
|
>
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
break
max_t = t if t > max_t else max_t
composition[comp_name][instr_name]["score"] = score
# Must be done after all note times keyed in, else you can't coordinate melodies with the rhythm chords
print '''f1 0 512 10 1
f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
f3 0 1025 10 1
'''
for comp_name in progression.split():
for instr_name, instr in composition[comp_name].iteritems():
composition[comp_name][instr_name]["score"] = transliterate_score(composition[comp_name][instr_name]["score"], key)
# print "\nMovement %s instrument %s" % (comp_name, instr_name)
# print composition[comp_name][instr_name]["score"]
final_score = generate_csound_score(composition[comp_name][instr_name]["score"], composition[comp_name][instr_name]["score_line"])
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
"B": "11",
}
csound_score = []
for token in score:
if isinstance(token, parse.Chord): # Chords
for note in token.chord:
note = csound_note_values[note]
csound_score.append(score_line % {"time": token.time, "octave": random.choice([7,8]), "note": note, "duration": token.duration})
elif isinstance(token, parse.Note): # Individual notes
note = csound_note_values[token.value]
csound_score.append(score_line % {"time": token.time, "octave": token.octave, "note": note, "duration": token.duration})
return csound_score
if __name__ == "__main__": main()
|
|
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
"B": "11",
}
csound_score = []
for token in score:
if isinstance(token, parse.Chord): # Chords
for note in token.chord:
note = csound_note_values[note]
csound_score.append(score_line % {"time": token.time, "octave": token.octave, "note": note, "duration": token.duration})
elif isinstance(token, parse.Note): # Individual notes
note = csound_note_values[token.value]
csound_score.append(score_line % {"time": token.time, "octave": token.octave, "note": note, "duration": token.duration})
return csound_score
if __name__ == "__main__": main()
|