genmidi: Update to support Python 3 build.

Tweak the code used to build the GENMIDI Lump so that it properly
supports Python 3 for build. Tested use cases were:
 * Normal build
 * a2i-to-sbi script to convert AdTrack2 instruments to SBI format
 * dumpgenmidi script to dump the instruments from a GENMIDI lump.
 * Running genmidi.py, sbi_file.py, a2i_file.py standalone to print the
   contents of files in their respective formats.
This commit is contained in:
Simon Howard 2014-10-28 03:55:22 +00:00
parent 8422d38ce4
commit e47b69a064
5 changed files with 37 additions and 39 deletions

View file

@ -215,17 +215,19 @@ def decode_type_9(data):
# Decode instrument name
ps = decompressed_data[14:]
instr_data["name"], = struct.unpack("%ip" % len(ps), ps)
instr_name, = struct.unpack("%ip" % len(ps), ps)
instr_data["name"] = instr_name.decode("ascii")
return instr_data
def read(filename):
f = open(filename)
data = f.read()
f.close()
with open(filename, "rb") as f:
data = f.read()
hdrstr, crc, filever = struct.unpack("<7sHB", data[0:10])
hdrstr = hdrstr.decode("ascii")
if hdrstr.lower() != HEADER_STRING.lower():
raise Exception("Wrong file header ID string")