Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make replayer code portable #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions convert/OidosConvert.py → convert/oidosconvert.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
#!/usr/bin/env python2

import sys
import zipfile
import XML
import oidosxml
import struct
import ctypes
import math
Expand Down Expand Up @@ -483,8 +483,8 @@ def roundup(v):
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)
Expand All @@ -502,8 +502,8 @@ def roundup(v):
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)
Expand All @@ -516,8 +516,8 @@ def roundup(v):
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]
Expand All @@ -537,13 +537,13 @@ def roundup(v):
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
Expand Down Expand Up @@ -912,7 +912,7 @@ def writefile(filename, s):
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
Expand Down
208 changes: 104 additions & 104 deletions convert/OidosUpgrade.py → convert/oidosupgrade.py
Original file line number Diff line number Diff line change
@@ -1,104 +1,104 @@
#!/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()
2 changes: 1 addition & 1 deletion convert/XML.py → convert/oidosxml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python

import xml.dom
import xml.dom.minidom
Expand Down Expand Up @@ -89,3 +88,4 @@ def readXML(filename):

def makeXML(xstring):
return XML([xml.dom.minidom.parseString(xstring)])

2 changes: 1 addition & 1 deletion convert/py2exe_setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2

from distutils.core import setup
import py2exe, sys, os
Expand Down
9 changes: 9 additions & 0 deletions easy_elf/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

../convert/oidosconvert.py music.xrns music.asm && \
nasm -felf32 -I ../player/ ../player/oidos.asm -o oidos.o && \
nasm -felf32 -I ../player/ ../player/random.asm -o random.o && \
cc -m32 ../player/play.c -o play.o && \
cc -m32 -o dump_wav oidos.o random.o play.o && \
rm -fv oidos.o random.o play.o music.asm

18 changes: 18 additions & 0 deletions easy_elf/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

This setup is for easily building an executable version of a piece of music
created using Oidos.

Proceed as follows:

1. Place your music here, named music.xrns.
2. Edit the music.txt file to contain the text you would like the executable
to print at startup.
3. Edit the wav_filename.txt file to contain the filename (without trailing
newline!) to which the wav writer executable shall write the music.
5. Run build.sh to get the executable which writes the music in WAV format to
the file specified in wav_filename.txt.

If no executables appear, the script encountered an error along the way.
Consult the output window text for details.

Enjoy!
9 changes: 9 additions & 0 deletions makedist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cp player/oidos.asm $DIST/player/
cp player/oidos.h $DIST/player/
cp player/oidos.inc $DIST/player/
cp player/play.asm $DIST/player/
cp player/play.c $DIST/player/
cp player/random.asm $DIST/player/

# Copy examples
Expand All @@ -54,6 +55,14 @@ cp examples/Songs/Punqtured-4k-Fntstc.xrns $DIST/easy_exe/music.xrns
mkdir -p $DIST/easy_exe/temp
cp -R easy_exe/tools $DIST/easy_exe/

# Copy easy_elf
mkdir -p $DIST/easy_elf
cp easy_elf/build.bat $DIST/easy_elf/
cp easy_elf/*.txt $DIST/easy_elf/
cp examples/Songs/Punqtured-4k-Fntstc.xrns $DIST/easy_elf/music.xrns
mkdir -p $DIST/easy_elf/temp
cp -R easy_elf/tools $DIST/easy_elf/

# Copy readme, history and license
cp README.md $DIST/
cp HISTORY.md $DIST/
Expand Down
Loading