spiffyscore

Diff
Login

Diff

Differences From Artifact [7509ae0a18]:

To Artifact [d189f30210]:


117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
#                },
                "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 (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







>
|
|
|







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#                },
                "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()