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
| #!/usr/bin/env python
import os
import random
import sys
import time
random.seed(time.time())
def main():
key = "C"
note_grammars = {
"u": ["I V I IV u", "I IV", "I VII IV" , "e"],
"e": [""],
}
chord_grammars = {
"u": ["I IV V IV I", "e"],
"e": [""]
}
compose_piece(key, note_grammars)
compose_piece(key, chord_grammars, chords=True)
def compose_piece(key, grammars, chords=False):
score = ""
while len(score.split()) < 15:
score = "u u u"
score = generate_score(score, grammars)
score = transliterate_score(score, key, chords)
score = generate_csound_score(score)
print "f1 0 256 10 1 0 3 ; sine wave function table"
for line in score:
print line
|
|
|
|
|
| 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
| #!/usr/bin/env python
import os
import random
import sys
import time
random.seed(time.time())
def main():
key = "A"
note_grammars = {
"u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u" , "e"],
"e": [""],
}
chord_grammars = {
"u": ["I IV V IV I u u", "I VII IV u u", "I V IV u u", "e"],
"e": [""]
}
compose_piece(key, note_grammars)
compose_piece(key, chord_grammars, chords=True)
def compose_piece(key, grammars, chords=False):
score = ""
while len(score.split()) < 200:
score = "u u u"
score = generate_score(score, grammars)
score = transliterate_score(score, key, chords)
score = generate_csound_score(score)
print "f1 0 256 10 1 0 3 ; sine wave function table"
for line in score:
print line
|