Overview
Comment: | Successfully got the program to output a MIDI file instead of a csound score |
---|---|
Timelines: | family | ancestors | descendants | both | feature/midi |
Files: | files | file ages | folders |
SHA1: |
befd61cab9abd44e8ac9a8962b324721 |
User & Date: | brian on 2011-11-15 22:08:44 |
Other Links: | branch diff | manifest | tags |
Context
2011-11-15
| ||
22:09 | Replaced csound support with midi support check-in: 0c3fb3e27f user: brian tags: develop | |
22:08 | Successfully got the program to output a MIDI file instead of a csound score Closed-Leaf check-in: befd61cab9 user: brian tags: feature/midi | |
15:47 | Attempted to make a csound based on midi. Failed. check-in: daa0ddb3ad user: brian tags: feature/midi | |
Changes
Modified parse.py from [a8d0994825] to [bcac1af73f].
︙ | |||
120 121 122 123 124 125 126 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | - + - - + + + + + + + + + + + - + | note.syncopate = p[2] def p_accidental(p): '''note : ACCIDENTAL note ''' if p[1] == "^": |
︙ |
Modified spiffyscore.py from [390f3e8450] to [caa7e9ffa7].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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 | + + | #!/usr/bin/env python from __future__ import division import ipdb import os import random import sys import time from midiutil.MidiFile import MIDIFile as midifile import parse import topsort import yaml import tree random.seed(time.time()) mymidi = midifile(15) def main(): composition = { "fm_test": { "intro": { "melody": { # Instrument 'melody' "score_line": "i2 %(time)f %(duration)f 7000 %(octave)d.%(note)s 2 6 5 1", |
︙ | |||
101 102 103 104 105 106 107 | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - - + + - - - - - - - - - - + + + + + + + + + + - + - - + + | "u": ["C/4 C/4 C/4 C/4"], }, }, }, }, "sync_test": { "body": { |
︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | + - + - + + + + | subsection[instr]["sync"] = None unordered_instrs.append([subsection[instr]["sync"], instr]) ordered_instrs = topsort.topsort(unordered_instrs) ordered_instrs.remove(None) # None used as a placeholder for sort order for instruments with no sync setting instrs = [] syncs = {} 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) |
︙ | |||
266 267 268 269 270 271 272 | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | + + + + - - + + - - - - - + - - - - - - - - + - - + - - + - + - + + - + | total = 0 for n in score: if not isinstance(n, tree.Tree): total += n.duration return total def get_midi_note(octave, note): return note + 12 * (octave+1) |