Differences From Artifact [019c552e42a3913f]:
- Executable file
cfg.py
- 2010-11-30 17:33:27 - part of checkin [843dabad43] on branch master - This is what I submitted as my final piece for MUS 306 (user: spiffytech@gmail.com) [annotate]
To Artifact [d386f64212558e44]:
- Executable file
cfg.py
- 2011-09-15 15:28:03 - part of checkin [33ddc6fee4] on branch feature/abc - Got the program to run through again. Now without the roman numerals (user: brian) [annotate]
11 11 def main():
12 12 key = "A"
13 13 bps = 60/60
14 14 tempo = 1/bps
15 15 max_duration = 1
16 16
17 17 composition = {
18 - "intro1": {
19 - "rhythm": {
20 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
21 - "octave": 7,
22 - "duration": 4,
23 - "grammars": {
24 - "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
25 - "w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
26 - "x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
27 - "y": ['"I" "vi"2 "IV" "V" y y u'],
28 - },
29 - "score": "u x u y x w u",
30 - },
31 - },
32 - "intro2": {
33 - "rhythm": {
34 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
35 - "octave": 7,
36 - "duration": 8,
37 - "grammars": {
38 - "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
39 - "w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
40 - "x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
41 - "y": ['"I" "vi"2 "IV" "V" y y u'],
42 - },
43 - "score": "u x u y x w u",
44 - },
45 - "timbre": {
46 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
47 - "octave": 6,
48 - "duration": 8,
49 - "grammars": { # Notes for this instrument to use in this piece
50 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
51 - },
52 - "score": "u u u u u",
53 - },
54 - },
55 18 "overview": {
56 19 "melody": { # Instrument 'melody'
57 20 "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
58 21 "octave": 8,
59 22 "duration": 40,
60 23 "grammars": { # Notes for this instrument to use in this piece
61 - "u": ["I V/2 V/2 V/2 I VII, IV' I IV I VII IV"],
62 - "w": ['III/4 VI/4 II/4 V/4 VI/4 IV/4 VII2'],
63 - "x": ['I/2 I/2 VI IV/2 V2 z I/2 I/2 VI IV/2 V'],
24 + "u": ["C G/2 G/2 G/2 C B, F' C F C B F"],
25 +# "w": ['E/4 A/4 D/4 G/4 F/4 F/4 B2'],
64 26 },
65 - "score": "u u w w w w w x x",
66 - },
67 - "rhythm": {
68 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
69 - "octave": 7,
70 - "duration": 44,
71 - "grammars": {
72 - "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
73 - "w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
74 - "x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
75 - "y": ['"I" "vi"2 "IV" "V" y y u'],
76 - },
77 - "score": "u x u y x w u",
78 - },
79 - "timbre": {
80 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
81 - "octave": 6,
82 - "duration": 44,
83 - "grammars": { # Notes for this instrument to use in this piece
84 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
85 - },
86 - "score": "u u u u u",
87 - },
88 - },
89 - "a": { # Movement block 'a' for reuse throughout the piece
90 - "melody": { # Instrument 'melody'
91 - "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
92 - "octave": 8,
93 - "duration": 40,
94 - "grammars": { # Notes for this instrument to use in this piece
95 - "u": ["I V/2 V/2 V/2 I VII, IV' x", "I IV w", "I VII IV u"],
96 - "w": ['VII I IV V VI VII I IV V VI VII u'],
97 - "x": ['VI/4 III/4 II/4 I/4 w'],
98 - },
99 - "score": "u",
100 - },
101 - "rhythm": {
102 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
103 - "octave": 7,
104 - "duration": 48,
105 - "grammars": {
106 - "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "ii" x u', '"I" "vii" "III" y u', '"I" "v" "IV" u u'],
107 - "w": ['"i" "VII"2 "VI"/4 "V"/4 "i"/4 "VII"2 "VI" "V" w u'],
108 - "x": ['"III/2" "VI"/2 "III"/2 "vii"2 "i"2 "V" u'],
109 - "y": ['"I" "vi"2 "IV" "V" y y u'],
110 - },
111 - "score": "u x u y x w u",
112 - },
113 - "timbre": {
114 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
115 - "octave": 6,
116 - "duration": 42,
117 - "grammars": { # Notes for this instrument to use in this piece
118 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
119 - },
120 - "score": "u u u u u",
121 - },
122 - },
123 - "b": { # Movement block 'a' for reuse throughout the piece
124 - "melody": { # Instrument 'melody'
125 - "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
126 - "octave": 8,
127 - "duration": 40,
128 - "grammars": { # Notes for this instrument to use in this piece
129 - "u": ['I VII V III u', "y"],
130 - "w": ['VII I IV V VI u', 'w'],
131 - "x": ['VI/4 III/4 II/4 I/4 w', 'x x'],
132 - "y": ["III/4 VI/4 II/4 V/4 VI/4 IV/4 VII2"],
133 - },
134 - "score": "w w x x w",
135 - },
136 - "rhythm": {
137 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
138 - "octave": 7,
139 - "duration": 44,
140 - "grammars": {
141 - "u": ['"I" "V" "vi" "iii" "IV" "I" "IV" "V" u u', "y"],
142 - "y": ['"I" "vi"2 "IV" "V" y y u'],
143 - },
144 - "score": "u u y y u",
145 - },
146 - "timbre": {
147 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
148 - "octave": 6,
149 - "duration": 40,
150 - "grammars": { # Notes for this instrument to use in this piece
151 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
152 - },
153 - "score": "u u u u u",
27 + "score": "u u",
154 28 },
155 29 },
156 - "zelda1": { # Movement block 'a' for reuse throughout the piece
157 - "melody": { # Instrument 'melody'
158 - "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
159 - "octave": 8,
160 - "duration": 50,
161 - "grammars": { # Notes for this instrument to use in this piece
162 - "u": ['I VI/2 VI/2 IV/2 I VI/2 VI/2 IV/2 I VI/2 VI/2 IV/2 w', "y"],
163 - "w": ['VII/2 I/2 II/2 V/2 u'],
164 - "x": ['VI/4 III/4 II/4 I/4 w'],
165 - "y": ["III/4 VI/4 II/4 V/4 VI/4 IV/4 VII2 x"],
166 - },
167 - "score": "w",
168 - },
169 - "rhythm": {
170 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
171 - "octave": 7,
172 - "duration": 54,
173 - "grammars": {
174 - "u": ['"I"/2 "V"/2 "vi"/2 "iii"/2 "IV"/2 "I"/2 "IV"/2 "V"/2 u u', "y"],
175 - "y": ['"I"/2 "vi" "IV"/2 "V"/2 y y u'],
176 - },
177 - "score": "u u y y u",
178 - },
179 - "timbre": {
180 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
181 - "octave": 6,
182 - "duration": 54,
183 - "grammars": { # Notes for this instrument to use in this piece
184 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
185 - },
186 - "score": "u u u u u",
187 - },
188 - },
189 - "zelda2": { # Movement block 'a' for reuse throughout the piece
190 - "melody": { # Instrument 'melody'
191 - "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
192 - "octave": 8,
193 - "duration": 40,
194 - "grammars": { # Notes for this instrument to use in this piece
195 - "u": ['I/2 I/2 VI IV/2 V2 z I/2 I/2 VI IV/2 V u', "w"],
196 - "w": ['III/2 II/2 IV/2 III/2 V/2 IV/2 VI/2 V/2 w', 'u', 'x'],
197 - "x": ['VII3 z2 V/4 IV/4 V/4 IV/4 V/4 VI/4 II/4 II/4 II/4 I/4 II/2 u', 'w'],
198 - },
199 - "score": "u",
200 - },
201 - "rhythm": {
202 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
203 - "octave": 7,
204 - "duration": 44,
205 - "grammars": {
206 - "u": ['"I"/2 "V"/2 "vi"/2 "iii"/2 "IV"/2 "I"/2 "IV"/2 "V"/2 u u', "y"],
207 - "y": ['"I"/2 "vi" "IV"/2 "V"/2 y y u'],
208 - },
209 - "score": "u u y y u",
210 - },
211 - "timbre": {
212 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
213 - "octave": 6,
214 - "duration": 44,
215 - "grammars": { # Notes for this instrument to use in this piece
216 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
217 - },
218 - "score": "u u u u u",
219 - },
220 - },
221 - "timbre_solo": { # Movement block 'a' for reuse throughout the piece
222 - "rhythm": {
223 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
224 - "octave": 7,
225 - "duration": 30,
226 - "grammars": {
227 - "u": ['"I"/2 "V"/2 "vi"/2 "iii"/2 "IV"/2 "I"/2 "IV"/2 "V"/2 u u', "y"],
228 - "y": ['"I"/2 "vi" "IV"/2 "V"/2 y y u'],
229 - },
230 - "score": "u u y y u",
231 - },
232 - "timbre": {
233 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
234 - "octave": 6,
235 - "duration": 30,
236 - "grammars": { # Notes for this instrument to use in this piece
237 - "u": ['I VI/2 VI/2 IV/2 u', "y"],
238 - "w": ['VII/2 I/2 II/2 V/2 u', 'w w', 'u x'],
239 - "x": ['VI/4 III/4 II/4 I/4 w', 'x x', 'x u'],
240 - "y": ["III/4 VI/4 II/4 V/4 VI/4 IV/4 VII2 w", 'y y'],
241 - },
242 - "score": "u",
243 - },
244 - },
245 - "outro1": { # Movement block 'a' for reuse throughout the piece
246 - "melody": { # Instrument 'melody'
247 - "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2",
248 - "octave": 8,
249 - "duration": 20,
250 - "grammars": { # Notes for this instrument to use in this piece
251 - "u": ['I VII V III u', "y"],
252 - "w": ['VII I IV V VI u', 'w w'],
253 - "x": ['VI/4 III/4 II/4 I/4 w', 'x x'],
254 - "y": ["III/4 VI/4 II/4 V/4 VI/4 IV/4 VII2"],
255 - },
256 - "score": "w w x x w",
257 - },
258 - "rhythm": {
259 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
260 - "octave": 7,
261 - "duration": 26,
262 - "grammars": {
263 - "u": ['"I" "V" "vi" "iii" "IV" "I" "IV" "V" u u', "y"],
264 - "y": ['"I" "vi"2 "IV" "V" y y u'],
265 - },
266 - "score": "u u y y u",
267 - },
268 - "timbre": {
269 - "score_line": "i3 %(time)f %(duration)f 2000 %(octave)d.%(note)s 2 3 5 3",
270 - "octave": 6,
271 - "duration": 26,
272 - "grammars": { # Notes for this instrument to use in this piece
273 - "u": ['I2 VII2 V2 VI2 I2 IV/2 V/2 III2 u', 'I2 IV2 V2 IV I V2 III2 II2 u']
274 - },
275 - "score": "u u u u u",
276 - },
277 - },
278 - "outro2": {
279 - "rhythm": {
280 - "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
281 - "octave": 7,
282 - "duration": 4,
283 - "grammars": {
284 - "u": ['"I" "V" "vi" "iii" "IV" "I" "IV" "V" u u', "y"],
285 - "y": ['"I" "vi"2 "IV" "V" y y u'],
286 - },
287 - "score": "u u y y u",
288 - },
289 - },
290 30 }
291 31
292 32 max_t = 0 # max time encountered so far. Used for movement timing
293 - progression = "intro1 intro2 overview a timbre_solo zelda1 b zelda2 outro1 outro2"
33 + progression = "overview"
294 34 # progression = "zelda1"
295 35 for comp_name in progression.split():
296 36 comp_start_time = max_t
297 37 for instr_name, instr in composition[comp_name].iteritems():
298 38 generated_score = generate_score(instr["score"], instr["grammars"]) # Fill in the scores by generating them based on the grammars
299 39 # print generated_score
40 + print generated_score
300 41 score = parse.parse(generated_score, default_octave=instr["octave"]) # Return Node/Chord objects
301 42
302 43 # Generate timestamps for the notes
303 44 t = comp_start_time
304 45 for note in range(len(score)):
305 46 score[note].time = t
306 47 score[note].duration *= tempo
................................................................................
318 59 print '''f1 0 512 10 1
319 60 f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
320 61 f3 0 1025 10 1
321 62 '''
322 63 for comp_name in progression.split():
323 64 print "; Movement:", comp_name
324 65 for instr_name, instr in composition[comp_name].iteritems():
325 - composition[comp_name][instr_name]["score"] = transliterate_score(composition[comp_name][instr_name]["score"], key)
66 +# composition[comp_name][instr_name]["score"] = transliterate_score(composition[comp_name][instr_name]["score"], key)
326 67 # print "\nMovement %s instrument %s" % (comp_name, instr_name)
327 68 # print composition[comp_name][instr_name]["score"]
328 69 final_score = generate_csound_score(composition[comp_name][instr_name]["score"], composition[comp_name][instr_name]["score_line"])
329 70 for line in final_score:
330 71 print line
331 72
332 73