101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
"u": ["C/4 C/4 C/4 C/4"],
},
},
},
},
"sync_test": {
"body": {
"lead_instr": { # Instrument 'melody'
"score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
"octave": 8,
"duration": 30,
"grammars": { # Notes for this instrument to use in this piece
"u": ["A/4, B/4, C/4 D/4 (u)", "D/4' D/4' D/4' D/4' (v)"],
"v": ["C/4 C/4 C/4 C/4 (w)"],
"w": ["E/4 F/4 E/4 F/4 (u)"],
},
},
"follow_instr": { # Instrument 'melody'
"score_line": "i3 %(time)f %(duration)f 7000 %(octave)d.%(note)s",
# "sync": "lead_instr",
"octave": 2,
"duration": 30,
"grammars": { # Notes for this instrument to use in this piece
"u": ["E F G E (u)"],
"v": ["G A A A (e)"],
"e": ["B' A' G' A' (v)"],
},
},
},
},
}
print '''f1 0 512 10 1
f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
"u": ["C/4 C/4 C/4 C/4"],
},
},
},
},
"sync_test": {
"body": {
# "lead_instr": { # Instrument 'melody'
# "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
# "octave": 8,
# "duration": 30,
# "grammars": { # Notes for this instrument to use in this piece
# "u": ["A/4, B/4, C/4 D/4 (u)", "D/4' D/4' D/4' D/4' (v)"],
# "v": ["C/4 C/4 C/4 C/4 (w)"],
# "w": ["E/4 F/4 E/4 F/4 (u)"],
# },
# },
"follow_instr": { # Instrument 'melody'
"score_line": "i3 %(time)f %(duration)f 7000 %(octave)d.%(note)s",
# "sync": "lead_instr",
"octave": 2,
"duration": 30,
"grammars": { # Notes for this instrument to use in this piece
"u": ["A ^A B C ^C D ^D E F ^F G ^G"],
# "u": ["E F G E (v)"],
# "v": ["G A A A (e)", "G A A A (v)"],
# "e": ["B A G A (v)"],
},
},
},
},
}
print '''f1 0 512 10 1
f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
total += n.duration
return total
def generate_csound_score(score, score_line, t):
csound_note_values = {
"C": "00",
"C#": "01",
"D": "02",
"D#": "03",
"E": "04",
"F": "05",
"F#": "06",
"G": "07",
"G#": "08",
"A": "09",
"A#": "10",
"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": t, "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": t, "octave": token.octave, "note": note, "duration": token.duration})
elif isinstance(token, tree.Tree):
continue
t += token.duration
return csound_score
if __name__ == "__main__": main()
|
|
|
|
|
|
>
|
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
total += n.duration
return total
def generate_csound_score(score, score_line, t):
csound_note_values = {
"C": "00",
"C#": "01", "Db": "01",
"D": "02",
"D#": "03", "Eb": "03",
"E": "04",
"F": "05",
"F#": "06", "Gb": "06",
"G": "07",
"G#": "08", "Ab": "08",
"A": "09",
"A#": "10", "Bb": "10",
"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": t, "octave": token.octave, "note": note, "duration": token.duration})
csound_score.append(score_line % {"time": t, "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": t, "octave": token.octave, "note": note, "duration": token.duration})
elif isinstance(token, tree.Tree):
continue
t += token.duration
return csound_score
if __name__ == "__main__": main()
|