genmidi: Output fixed_note as constant value.

Generate output that uses the more readable constants from midi.py instead
of just a MIDI note number.
This commit is contained in:
Simon Howard 2012-01-04 01:47:49 +00:00
parent b0253e3176
commit b6b9cf999e
2 changed files with 13 additions and 1 deletions

View file

@ -37,6 +37,7 @@
import genmidi
import sbi_file
import sys
import midi
def print_instr_def(filename, filename2, instr):
result = "Instrument(\"%s\"" % filename
@ -45,7 +46,7 @@ def print_instr_def(filename, filename2, instr):
result += (", \"%s\"" % filename2)
if instr.fixed_note is not None:
result += (", note=%i" % instr.fixed_note)
result += (", note=%s" % midi.def_for_note(instr.fixed_note))
if instr.offset1 != 0:
result += (", off1=%i" % instr.offset1)
if instr.offset2 != 0:

View file

@ -71,3 +71,14 @@ O3 = Octave(96) # Octave 3
O4 = Octave(108) # Octave 4
O5 = Octave(120) # Octave 5
# Given a MIDI note number, return a note definition in terms of the
# constants above.
def def_for_note(note):
OCTAVES = [ "On5", "On4", "On3", "On2", "On1",
"O0", "O1", "O2", "O3", "O4", "O5" ]
NOTES = [ "C", "Cs", "D", "Ds", "E", "F", "Fs",
"G", "Gs", "A", "As", "B" ]
return "%s.%s" % (OCTAVES[note / 12], NOTES[note % 12])