ws-audio2: music/669 (Composer 669 / UNIS 669): s3m family with Hz periods, fast + auto slides, frequency adjust, per-pattern speed and break rows

This commit is contained in:
4DBug committed 2026-10-31 14:13:48 -05:00
1 parent 384cdc407d
commit 33d87e0c4d
6 files changed
+366 -1

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
# 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)
+30
View File
@@ -545,3 +545,33 @@ def write_mtm(title, samples, orders, patterns, channels, pans=None, rows=64, co
def u16(xs):
return b"".join(struct.pack("<H", max(0, min(65535, int(round(x * 32767)) + 32768))) for x in xs)
def write_669(message, samples, orders, patterns, tempos, breaks, restart=0, extended=False):
"""samples: [{name, data (unsigned bytes), loop: (start, end) | None}]; patterns: [[row: [(note, ins, vol, effect)]
* 8] * 64] with note 0 = none else our note (>= 37), ins 1-based, vol 0..15 or None, effect byte (cmd << 4 | param)
or None; tempos / breaks: per pattern"""
out = bytearray(b"JN" if extended else b"if")
msg = message.encode()[:108]
out += msg + b" " * (108 - len(msg))
out += bytes([len(samples), len(patterns), restart])
out += bytes(orders) + b"\xff" * (128 - len(orders))
out += bytes(tempos) + b"\x04" * (128 - len(tempos))
out += bytes(breaks) + b"\x3f" * (128 - len(breaks))
for s in samples:
ls, le = s.get("loop") or (0, 0xFFFFF)
out += name(s.get("name", ""), 13) + struct.pack("<III", len(s["data"]), ls, le)
for pat in patterns:
for row in pat:
for (note, ins, vol, eff) in row:
if note:
n, i = note - 37, ins - 1
out += bytes([(n << 2) | (i >> 4), ((i & 15) << 4) | (vol if vol is not None else 0)])
elif vol is not None:
out += bytes([0xFE, vol])
else:
out += b"\xff\x00"
out.append(0xFF if eff is None else eff)
for s in samples:
out += s["data"]
return bytes(out)