Overview
| Comment: | If I move from csound to midi I should actually rename function with 'csound' in the name |
|---|---|
| Timelines: | family | ancestors | descendants | both | develop |
| Files: | files | file ages | folders |
| SHA1: |
872ae930598cac24eced9515f360579e |
| User & Date: | brian on 2011-11-16 00:14:47.135 |
| Other Links: | branch diff | manifest | tags |
Context
|
2011-11-17
| ||
| 19:55 | Removed leftover csound function lines that got printed. Also disabled ipdb so I get concise stacktraces. Also made program crash when your score pointed to a non-existant node. Previously that just generated an invalid MIDI file (somehow...) check-in: f8034c7dfb user: brian tags: develop | |
|
2011-11-16
| ||
| 00:14 | If I move from csound to midi I should actually rename function with 'csound' in the name check-in: 872ae93059 user: brian tags: develop | |
|
2011-11-15
| ||
| 22:12 | Removed useless samples and test csound files now that we're no longer using csound check-in: 680f187463 user: brian tags: develop | |
Changes
parse.py became
a regular file with contents
[bcac1af73f].
Modified spiffyscore.py
from [caa7e9ffa7]
to [5ac9fc3252].
| ︙ | ︙ | |||
15 16 17 18 19 20 21 |
import tree
random.seed(time.time())
mymidi = midifile(15)
def main():
composition = {
| < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < < < < < < < < < < < < < | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import tree
random.seed(time.time())
mymidi = midifile(15)
def main():
composition = {
"intro": {
"body": {
"lead_instr": { # Instrument 'melody'
"channel": 6,
"octave": 4,
"duration": 30,
"grammars": { # Notes for this instrument to use in this piece
"u": ["A/2, B/2, C/2 D/2 (u)", "D2' D2' D2' D2' (x)"],
"v": ["C/2 C/2 C/2 C/2 (w)"],
"w": ["E/2 F/2 E/2 F/2 (u)"],
"x": ["z4 (v)"],
},
},
"follow_instr": { # Instrument 'bass'
"channel": 4,
"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 (u)"],
"x": ["z4 (e)"],
},
},
},
},
}
print '''f1 0 512 10 1
f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
f3 0 1025 10 1
t 0 60
'''
section_start = 0
for section in ["intro"]:
print "; Section " + section
subsection_start = section_start
section = composition[section]
for subsection in ["intro", "body", "outro"]:
try:
print "; Subsection " + subsection
subsection = section[subsection]
|
| ︙ | ︙ | |||
178 179 180 181 182 183 184 |
track = 0
for instr in ordered_instrs:
print ";Instrument " + instr
instr = subsection[instr]
max_time = instr["duration"]
instr_score, syncs = render_instr(instr, syncs, max_time)
instrs.append(instr_score)
| | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
track = 0
for instr in ordered_instrs:
print ";Instrument " + instr
instr = subsection[instr]
max_time = instr["duration"]
instr_score, syncs = render_instr(instr, syncs, max_time)
instrs.append(instr_score)
midify_instr_score(instr_score, track, instr["channel"], subsection_start)
longest_score = max(instrs, key=lambda i: score_len(i))
subsection_start += score_len(longest_score)
section_start += score_len(longest_score)
track += 1
except KeyError:
pass
with open("out.mid", "wb") as outfile:
|
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
return total
def get_midi_note(octave, note):
return note + 12 * (octave+1)
| | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
return total
def get_midi_note(octave, note):
return note + 12 * (octave+1)
def midify_instr_score(score, track, channel, t):
# Assume get_midi_note()
global mymidi
for token in score:
if isinstance(token, parse.Chord): # Chords
for note in token.chord:
note = get_midi_note(token.octave, note)
|
| ︙ | ︙ |