Differences From Artifact [43fd8f5bb3819142]:
- Executable file
cfg.py
- 2010-11-13 00:12:38 - part of checkin [5aa14570f1] on branch ply - Now handles chords (user: spiffytech@gmail.com) [annotate]
To Artifact [df0a6863becf2cac]:
- Executable file
cfg.py
- 2010-11-13 08:26:53 - part of checkin [729263ecd0] on branch ply - Added basic ABC tokenizing via the PLY module (user: spiffytech@gmail.com) [annotate]
3 import os 3 import os
4 import random 4 import random
5 import sys 5 import sys
6 import time 6 import time
7 random.seed(time.time()) 7 random.seed(time.time())
8 8
9 def main(): 9 def main():
10 key = "C" | 10 key = "A"
11 note_grammars = { 11 note_grammars = {
12 "u": ["I V I IV u", "I IV", "I VII IV" , "e"], | 12 "u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u" , "e"],
13 "e": [""], 13 "e": [""],
14 } 14 }
15 chord_grammars = { 15 chord_grammars = {
16 "u": ["I IV V IV I", "e"], | 16 "u": ["I IV V IV I u u", "I VII IV u u", "I V IV u u", "e"],
17 "e": [""] 17 "e": [""]
18 } 18 }
19 compose_piece(key, note_grammars) 19 compose_piece(key, note_grammars)
20 compose_piece(key, chord_grammars, chords=True) 20 compose_piece(key, chord_grammars, chords=True)
21 21
22 def compose_piece(key, grammars, chords=False): 22 def compose_piece(key, grammars, chords=False):
23 score = "" 23 score = ""
24 while len(score.split()) < 15: | 24 while len(score.split()) < 200:
25 score = "u u u" 25 score = "u u u"
26 score = generate_score(score, grammars) 26 score = generate_score(score, grammars)
27 score = transliterate_score(score, key, chords) 27 score = transliterate_score(score, key, chords)
28 score = generate_csound_score(score) 28 score = generate_csound_score(score)
29 print "f1 0 256 10 1 0 3 ; sine wave function table" 29 print "f1 0 256 10 1 0 3 ; sine wave function table"
30 for line in score: 30 for line in score:
31 print line 31 print line