95 lines
3.7 KiB
Python
95 lines
3.7 KiB
Python
# 669 fixtures (tools/fixtures.py): generated Composer 669 / UNIS 669 modules exercising the effects, rendered by
|
|
# openmpt123.
|
|
# tests/gen/669_cases.luau { name, data (the module), ref (features of openmpt's render, tools/fixtures/_tracker.py),
|
|
# duration (openmpt's song length) }
|
|
import os, sys
|
|
|
|
# the shared tracker module, loaded by path (tools/fixtures/ must not go on sys.path: xml.py there would shadow xml)
|
|
T = sys.modules.get("_tracker")
|
|
if T is None:
|
|
import importlib.util
|
|
_spec = importlib.util.spec_from_file_location("_tracker", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_tracker.py"))
|
|
T = importlib.util.module_from_spec(_spec)
|
|
sys.modules["_tracker"] = T
|
|
_spec.loader.exec_module(T)
|
|
|
|
INPUTS = ["tools/fixtures/_tracker.py"]
|
|
|
|
|
|
def empty():
|
|
return [[(0, 0, None, None) for _ in range(8)] for _ in range(64)]
|
|
|
|
|
|
def put(p, row, ch, note=0, ins=0, vol=None, cmd=None, param=0):
|
|
p[row][ch] = (note, ins, vol, None if cmd is None else (cmd << 4) | param)
|
|
|
|
|
|
def samples():
|
|
return [
|
|
{"name": "sine", "data": T.u8(T.synth("sine", 64, 64)), "loop": (0, 64)},
|
|
{"name": "square", "data": T.u8(T.synth("square", 64, 64, 0.5)), "loop": (0, 64)},
|
|
{"name": "saw", "data": T.u8(T.synth("saw", 100, 100, 0.6)), "loop": (0, 100)},
|
|
{"name": "noise", "data": T.u8(T.synth("noise", 6000, 1, 0.7, decay=1500))},
|
|
{"name": "tri", "data": T.u8(T.synth("tri", 50, 50, 0.8)), "loop": (0, 50)},
|
|
]
|
|
|
|
|
|
def song_effects(keep=None):
|
|
a, b = empty(), empty()
|
|
mel = [61, 65, 68, 73, 68, 65, 63, 61]
|
|
for i in range(16):
|
|
put(a, i * 4, 0, mel[i % 8], 1, 15)
|
|
put(a, 0, 1, 49, 2, 12)
|
|
put(a, 8, 1, 0, 0, None, 0, 2) # auto portamento up (runs until the next effect)
|
|
put(a, 16, 1, 0, 0, None, 1, 3) # auto portamento down
|
|
put(a, 24, 1, 0, 0, None, 5, 3) # speed (stops the auto slide)
|
|
put(a, 28, 1, 56, 2, 10)
|
|
put(a, 32, 1, 61, 2, None, 2, 2) # tone portamento (keeps going)
|
|
put(a, 40, 1, 49, 2, None, 2, 4)
|
|
put(a, 48, 1, 0, 0, 6, 3, 5) # frequency adjust
|
|
put(a, 52, 1, 0, 0, None, 4, 3) # frequency vibrato
|
|
for r in range(0, 64, 8):
|
|
put(a, r, 3, 61, 4, 15 - r // 8)
|
|
put(a, 4, 2, 37, 3, 15)
|
|
put(a, 36, 2, 0, 0, 4)
|
|
put(a, 10, 4, 73, 5, 9)
|
|
put(a, 20, 4, 0, 0, None, 4, 6)
|
|
# b: speed per pattern, a break row, more slides
|
|
put(b, 0, 0, 49, 1, 15)
|
|
put(b, 4, 0, 0, 0, None, 1, 1)
|
|
put(b, 12, 0, 61, 1, 15)
|
|
put(b, 16, 0, 0, 0, None, 0, 1)
|
|
put(b, 20, 0, 0, 0, 10, None)
|
|
put(b, 0, 2, 37, 3, 12)
|
|
put(b, 8, 2, 44, 3, None, 2, 1)
|
|
put(b, 24, 2, 0, 0, None, 3, 2)
|
|
put(b, 0, 5, 56, 5, 13)
|
|
put(b, 16, 5, 52, 2, 13)
|
|
if keep is not None:
|
|
for p in (a, b):
|
|
for row in p:
|
|
for ch in range(8):
|
|
if ch not in keep:
|
|
row[ch] = (0, 0, None, None)
|
|
return T.write_669("effects 669", samples(), [0, 1], [a, b], [4, 3], [63, 40])
|
|
|
|
|
|
def song_unis():
|
|
"""UNIS 669: balance slides, slot retrigger, a restart position"""
|
|
a = empty()
|
|
put(a, 0, 0, 61, 1, 15, 6, 0) # balance slide left (repeats until the next note)
|
|
put(a, 16, 0, 64, 1, 15, 6, 1) # right
|
|
put(a, 32, 1, 49, 4, 15, 7, 3) # slot retrigger
|
|
put(a, 40, 1, 49, 4, 15, 7, 6)
|
|
put(a, 8, 2, 68, 2, 11)
|
|
put(a, 48, 3, 56, 3, 14)
|
|
return T.write_669("unis", samples(), [0, 0], [a], [5], [63], extended=True)
|
|
|
|
|
|
def generate(ctx):
|
|
cases = []
|
|
for nm, data in (("effects", song_effects()), ("unis", song_unis())):
|
|
ref = T.reference(ctx, data, "669")
|
|
cases.append({"name": nm, "data": data, "ref": ref, "duration": ref["duration"]})
|
|
ctx.emit("669_cases", cases)
|