spiffyscore
Diff
Not logged in

Differences From Artifact [f6edc4689fdace88]:

To Artifact [79cec58b407b1335]:


8 import parse 8 import parse 9 9 10 def main(): 10 def main(): 11 key = "A" 11 key = "A" 12 12 13 composition = { 13 composition = { 14 "a": { # Movement block 'a' for reuse throughout the piece 14 "a": { # Movement block 'a' for reuse throughout the piece 15 "melody": { # Instrument 'melody' | 15 # "melody": { # Instrument 'melody' 16 "csound_parameters": { | 16 # "csound_parameters": { 17 "instrument": 1, | 17 # "instrument": 1, 18 }, | 18 # }, 19 "grammars": { # Notes for this instrument to use in this piece | 19 # "grammars": { # Notes for this instrument to use in this piece 20 "u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u" , "e | 20 # "u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u" , " 21 "e": [""], | 21 # "e": [""], 22 }, | 22 # }, 23 "score": "u u u", | 23 # "score": "u u u", 24 }, | 24 # }, 25 "rhythm": { 25 "rhythm": { 26 "csound_parameters": { 26 "csound_parameters": { 27 "instrument": 1, 27 "instrument": 1, 28 }, 28 }, 29 "grammars": { 29 "grammars": { 30 "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', | 30 # "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "I" u u', '"I" "v > 31 "u": ['"i" "I" "ii" "II" "v" "V" u', "e"], 31 "e": [""] 32 "e": [""] 32 }, 33 }, 33 "score": "u u u", 34 "score": "u u u", 34 }, 35 }, 35 }, 36 }, 36 "b": { | 37 # "b": { 37 "melody": { # Instrument 'melody' | 38 # "melody": { # Instrument 'melody' 38 "csound_parameters": { | 39 # "csound_parameters": { 39 "instrument": 1, | 40 # "instrument": 1, 40 }, < > 41 # }, 41 "grammars": { # Notes for this instrument to use in this piece | 42 # "grammars": { # Notes for this instrument to use in this piece 42 "u": ["I V I I/2 IV/2 u u", "I4 IV u u", "I IV IV VI V u u" | 43 # "u": ["I V I I/2 IV/2 u u", "I4 IV u u", "I IV IV VI V u u" 43 "e": [""], | 44 # "e": [""], 44 }, < > 45 # }, 45 "score": "u u u", | 46 # "score": "u u u", 46 }, < > 47 # }, 47 "rhythm": { | 48 # "rhythm": { 48 "csound_parameters": { | 49 # "csound_parameters": { 49 "instrument": 1, | 50 # "instrument": 1, 50 }, < > 51 # }, 51 "grammars": { | 52 # "grammars": { 52 "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', | 53 # "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', 53 "e": [""] | 54 # "e": [""] 54 }, < > 55 # }, 55 "score": "u u u", | 56 # "score": "u u u", 56 }, < 57 }, | 57 # }, > 58 # }, 58 } 59 } 59 60 60 for comp_name, comp in composition.iteritems(): 61 for comp_name, comp in composition.iteritems(): 61 for instr_name, instr in comp.iteritems(): 62 for instr_name, instr in comp.iteritems(): 62 generated_score = generate_score(instr["score"], instr["grammars"]) 63 generated_score = generate_score(instr["score"], instr["grammars"]) 63 # composition[comp_name][instr_name][grammar]["score"] = parse.pa 64 # composition[comp_name][instr_name][grammar]["score"] = parse.pa 64 score = parse.parse(generated_score) # Return Node/Chord objects 65 score = parse.parse(generated_score) # Return Node/Chord objects ................................................................................................................................................................................ 125 for i in range(len(score)): 126 for i in range(len(score)): 126 if isinstance(score[i], parse.Note): 127 if isinstance(score[i], parse.Note): 127 score[i].value = scale[scale_conversion[score[i].value]-1] 128 score[i].value = scale[scale_conversion[score[i].value]-1] 128 else: 129 else: 129 chord = [] 130 chord = [] 130 root_note_index = scale.index(key) + scale_conversion[score[i].value 131 root_note_index = scale.index(key) + scale_conversion[score[i].value 131 chord.append(scale[root_note_index]) 132 chord.append(scale[root_note_index]) > 133 if score[i].chord_type == "m": # Minor chords, flat the 3rd > 134 chord.append(scale[(root_note_index+2) % 8]) > 135 else: 132 chord.append(scale[(root_note_index+3) % 8]) | 136 chord.append(scale[(root_note_index+3) % 8]) 133 chord.append(scale[(root_note_index+5) % 8]) 137 chord.append(scale[(root_note_index+5) % 8]) 134 score[i].chord = chord 138 score[i].chord = chord 135 return score 139 return score 136 140 137 141 138 def generate_csound_score(score): 142 def generate_csound_score(score): 139 csound_note_values = { 143 csound_note_values = {