mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-03 10:25:46 -04:00
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:
parent
b0253e3176
commit
b6b9cf999e
2 changed files with 13 additions and 1 deletions
|
@ -37,6 +37,7 @@
|
||||||
import genmidi
|
import genmidi
|
||||||
import sbi_file
|
import sbi_file
|
||||||
import sys
|
import sys
|
||||||
|
import midi
|
||||||
|
|
||||||
def print_instr_def(filename, filename2, instr):
|
def print_instr_def(filename, filename2, instr):
|
||||||
result = "Instrument(\"%s\"" % filename
|
result = "Instrument(\"%s\"" % filename
|
||||||
|
@ -45,7 +46,7 @@ def print_instr_def(filename, filename2, instr):
|
||||||
result += (", \"%s\"" % filename2)
|
result += (", \"%s\"" % filename2)
|
||||||
|
|
||||||
if instr.fixed_note is not None:
|
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:
|
if instr.offset1 != 0:
|
||||||
result += (", off1=%i" % instr.offset1)
|
result += (", off1=%i" % instr.offset1)
|
||||||
if instr.offset2 != 0:
|
if instr.offset2 != 0:
|
||||||
|
|
|
@ -71,3 +71,14 @@ O3 = Octave(96) # Octave 3
|
||||||
O4 = Octave(108) # Octave 4
|
O4 = Octave(108) # Octave 4
|
||||||
O5 = Octave(120) # Octave 5
|
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])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue