Commit 50214728 authored by PoroCYon's avatar PoroCYon
Browse files

make converter code portable

parent a51a2497
#!/usr/bin/env python
#!/usr/bin/env python2
import sys
import zipfile
import XML
import oidosxml
import struct
import ctypes
import math
......@@ -483,8 +483,8 @@ class Music:
self.out += "\n%define USES_PANNING\n"
# Instrument parameters
self.out += "\n\n\tsection iparam data align=4\n"
self.out += "\n_InstrumentParams:\n"
self.out += "\n\n\tSECT_DATA(iparam) align=4\n"
self.out += "\nInstrumentParams:\n"
for instr in self.instruments:
self.label(".i%02d" % instr.number)
self.comment(instr.title)
......@@ -502,8 +502,8 @@ class Music:
self.out += "\n"
# Instrument tones
self.out += "\n\n\tsection itones data align=1\n"
self.out += "\n_InstrumentTones:\n"
self.out += "\n\n\tSECT_DATA(itones) align=1\n"
self.out += "\nInstrumentTones:\n"
for instr in self.instruments:
self.label(".i%02d" % instr.number)
self.comment(instr.title)
......@@ -516,8 +516,8 @@ class Music:
self.out += "%d\n" % (-129 + instr.columns)
# Track data
self.out += "\n\n\tsection trdata data align=1\n"
self.out += "\n_TrackData:\n"
self.out += "\n\n\tSECT_DATA(trdata) align=1\n"
self.out += "\nTrackData:\n"
for ti in self.track_order:
track = self.tracks[ti]
instr = self.instrument_map[track.instr]
......@@ -537,13 +537,13 @@ class Music:
self.dataline(tavdata)
# Lengths of notes
self.out += "\n\tsection notelen data align=1\n"
self.out += "\n_NoteLengths:\n"
self.out += "\n\tSECT_DATA(notelen) align=1\n"
self.out += "\nNoteLengths:\n"
self.notelist(self.lendata, [0], "L_")
# Samples for notes
self.out += "\n\tsection notesamp data align=1\n"
self.out += "\n_NoteSamples:\n"
self.out += "\n\tSECT_DATA(notesamp) align=1\n"
self.out += "\nNoteSamples:\n"
self.notelist(self.samdata, [], "S_")
return self.out
......@@ -912,7 +912,7 @@ if len(files) != 2:
infile = files[0]
outfile = files[1]
x = XML.makeXML(zipfile.ZipFile(infile).read("Song.xml"))
x = oidosxml.makeXML(zipfile.ZipFile(infile).read("Song.xml"))
try:
music = makeMusic(x.RenoiseSong)
print
......
#!/usr/bin/env python
import sys
import zipfile
import XML
import re
import math
import base64
import struct
def upgradeInstrument(xi, xdevice, name):
def newname(s):
return re.sub("MetaSynth", "Oidos", s)
xdevice.PluginIdentifier.replaceText(newname)
xdevice.PluginDisplayName.replaceText(newname)
xdevice.PluginShortDisplayName.replaceText(newname)
if name is not None:
xi.Name.setData(name)
else:
xi.Name.replaceText(newname)
#pdata = base64.b64decode(xdevice.ParameterChunk.domlist[0].childNodes[0].data + "=")
#for i,c in enumerate(pdata):
# print "%s%02X" % (" " if (i % 4) == 0 else "", ord(c)),
#print
xparams = xdevice.Parameters.Parameter.Value
params = [float(p) for p in xparams]
# Duplicate filter sweep parameter
params = params[:11] + [params[13]] + params[11:17] + [0.0] + params[20:27] + [params[29]] + params[27:33]
for i,p in enumerate(params):
xparams[i].setData(p)
pstring = struct.pack("<4I", 1, 1, len(params), 0) + struct.pack("<%df" % len(params), *params)
xdevice.ParameterChunk.setData(base64.b64encode(pstring))
def upgradeInstruments(xinstrs, name):
for xi in xinstrs:
for xdevice in xi.PluginProperties.PluginDevice:
plugin_id = str(xdevice.PluginIdentifier)
if plugin_id == "MetaSynth":
upgradeInstrument(xi, xdevice, name)
break
def upgradeReverb(xdevice):
def newname(s):
return re.sub("MetaEffect", "OidosReverb", s)
xdevice.PluginIdentifier.replaceText(newname)
xdevice.PluginDisplayName.replaceText(newname)
xdevice.PluginShortDisplayName.replaceText(newname)
#pdata = base64.b64decode(xdevice.ParameterChunk.domlist[0].childNodes[0].data + "=")
#for i,c in enumerate(pdata):
# print "%s%02X" % (" " if (i % 4) == 0 else "", ord(c)),
#print
xparams = xdevice.Parameters.Parameter.Value
params = [float(p) for p in xparams]
# Reduce parameters
params = params[:20]
while len(xdevice.Parameters.Parameter) > 20:
xdevice.Parameters.removeChild(xdevice.Parameters.Parameter[20])
pstring = struct.pack("<4I", 1, 1, len(params), 0) + struct.pack("<%df" % len(params), *params)
xdevice.ParameterChunk.setData(base64.b64encode(pstring))
def upgradeReverbs(xtrack):
for xdevice in xtrack.FilterDevices.Devices.AudioPluginDevice:
plugin_id = str(xdevice.PluginIdentifier)
if plugin_id == "MetaEffect":
upgradeReverb(xdevice)
infile = sys.argv[1]
outfile = sys.argv[2]
zfile = zipfile.ZipFile(infile)
if infile.endswith(".xrns"):
info = zfile.getinfo("Song.xml")
x = XML.makeXML(zfile.read(info))
upgradeInstruments(x.RenoiseSong.Instruments.Instrument, None)
upgradeReverbs(x.RenoiseSong.Tracks.SequencerTrack)
upgradeReverbs(x.RenoiseSong.Tracks.SequencerSendTrack)
elif infile.endswith(".xrni"):
info = zfile.getinfo("Instrument.xml")
x = XML.makeXML(zfile.read(info))
upgradeInstruments(x.RenoiseInstrument, infile[infile.rfind('/')+1:-5])
else:
print "Unknown file extension: " + infile
sys.exit()
outzip = zipfile.ZipFile(outfile, 'w')
outzip.writestr(info, x.export())
outzip.close()
#!/usr/bin/env python2
import sys
import zipfile
import oidosxml
import re
import math
import base64
import struct
def upgradeInstrument(xi, xdevice, name):
def newname(s):
return re.sub("MetaSynth", "Oidos", s)
xdevice.PluginIdentifier.replaceText(newname)
xdevice.PluginDisplayName.replaceText(newname)
xdevice.PluginShortDisplayName.replaceText(newname)
if name is not None:
xi.Name.setData(name)
else:
xi.Name.replaceText(newname)
#pdata = base64.b64decode(xdevice.ParameterChunk.domlist[0].childNodes[0].data + "=")
#for i,c in enumerate(pdata):
# print "%s%02X" % (" " if (i % 4) == 0 else "", ord(c)),
#print
xparams = xdevice.Parameters.Parameter.Value
params = [float(p) for p in xparams]
# Duplicate filter sweep parameter
params = params[:11] + [params[13]] + params[11:17] + [0.0] + params[20:27] + [params[29]] + params[27:33]
for i,p in enumerate(params):
xparams[i].setData(p)
pstring = struct.pack("<4I", 1, 1, len(params), 0) + struct.pack("<%df" % len(params), *params)
xdevice.ParameterChunk.setData(base64.b64encode(pstring))
def upgradeInstruments(xinstrs, name):
for xi in xinstrs:
for xdevice in xi.PluginProperties.PluginDevice:
plugin_id = str(xdevice.PluginIdentifier)
if plugin_id == "MetaSynth":
upgradeInstrument(xi, xdevice, name)
break
def upgradeReverb(xdevice):
def newname(s):
return re.sub("MetaEffect", "OidosReverb", s)
xdevice.PluginIdentifier.replaceText(newname)
xdevice.PluginDisplayName.replaceText(newname)
xdevice.PluginShortDisplayName.replaceText(newname)
#pdata = base64.b64decode(xdevice.ParameterChunk.domlist[0].childNodes[0].data + "=")
#for i,c in enumerate(pdata):
# print "%s%02X" % (" " if (i % 4) == 0 else "", ord(c)),
#print
xparams = xdevice.Parameters.Parameter.Value
params = [float(p) for p in xparams]
# Reduce parameters
params = params[:20]
while len(xdevice.Parameters.Parameter) > 20:
xdevice.Parameters.removeChild(xdevice.Parameters.Parameter[20])
pstring = struct.pack("<4I", 1, 1, len(params), 0) + struct.pack("<%df" % len(params), *params)
xdevice.ParameterChunk.setData(base64.b64encode(pstring))
def upgradeReverbs(xtrack):
for xdevice in xtrack.FilterDevices.Devices.AudioPluginDevice:
plugin_id = str(xdevice.PluginIdentifier)
if plugin_id == "MetaEffect":
upgradeReverb(xdevice)
infile = sys.argv[1]
outfile = sys.argv[2]
zfile = zipfile.ZipFile(infile)
if infile.endswith(".xrns"):
info = zfile.getinfo("Song.xml")
x = oidosxml.makeXML(zfile.read(info))
upgradeInstruments(x.RenoiseSong.Instruments.Instrument, None)
upgradeReverbs(x.RenoiseSong.Tracks.SequencerTrack)
upgradeReverbs(x.RenoiseSong.Tracks.SequencerSendTrack)
elif infile.endswith(".xrni"):
info = zfile.getinfo("Instrument.xml")
x = oidosxml.makeXML(zfile.read(info))
upgradeInstruments(x.RenoiseInstrument, infile[infile.rfind('/')+1:-5])
else:
print "Unknown file extension: " + infile
sys.exit()
outzip = zipfile.ZipFile(outfile, 'w')
outzip.writestr(info, x.export())
outzip.close()
#!/usr/bin/env python
import xml.dom
import xml.dom.minidom
......@@ -89,3 +88,4 @@ def readXML(filename):
def makeXML(xstring):
return XML([xml.dom.minidom.parseString(xstring)])
#!/usr/bin/env python
#!/usr/bin/env python2
from distutils.core import setup
import py2exe, sys, os
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment