ws-music: music/s3m read + render (OpenMPT-matched master volume / mono rule / default panning), finer comparison bands, voice ownership fix
This commit is contained in:
1 parent
ac3e143ce8
commit
cf7c1b8ad2
12 files changed
+598
-15
No files matched your search
@@ -1,14 +1,14 @@
|
||||
# Tracker fixture helpers (used by tools/fixtures/{mod,s3m,xm,it}.py): small writers for MOD, S3M, XM and IT
|
||||
# (including IT 2.14 / 2.15 sample compression), synthesized samples, reference renders through openmpt123 (nix
|
||||
# libopenmpt) and the comparison features (per 2048-frame block: RMS of left / right / mid and 20 log-spaced band
|
||||
# libopenmpt) and the comparison features (per 2048-frame block: RMS of left / right / mid and 40 log-spaced band
|
||||
# magnitudes of the mid signal), computed the same way in tests/music/_similar.luau. Every module is generated here
|
||||
# (no third-party files), so the fixtures carry no licence.
|
||||
import json, math, os, struct, subprocess, tempfile
|
||||
|
||||
SR = 44100
|
||||
HOP = 2048
|
||||
BANDS = 20
|
||||
F_LO, F_HI = 100.0, 16000.0
|
||||
BANDS = 40
|
||||
F_LO, F_HI = 150.0, 16000.0
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------- samples
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
# S3M fixtures (tools/fixtures.py): generated Scream Tracker 3 modules exercising the effects, rendered by openmpt123.
|
||||
# tests/gen/s3m_cases.luau { name, data (the module), ref (features of openmpt's render, tools/fixtures/_tracker.py),
|
||||
# duration (openmpt's song length) }
|
||||
import os, sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import _tracker as T # noqa: E402
|
||||
|
||||
INPUTS = ["tools/fixtures/_tracker.py"]
|
||||
|
||||
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, Tt, U, V, W, X, Y, Z = range(1, 27)
|
||||
|
||||
|
||||
def empty(ch, rows=64):
|
||||
return [[(0, 0, None, 0, 0) for _ in range(ch)] for _ in range(rows)]
|
||||
|
||||
|
||||
def put(p, row, ch, note=0, ins=0, vol=None, cmd=0, info=0):
|
||||
p[row][ch] = (T.s3m_note(note) if 0 < note < 254 else note, ins, vol, cmd, info)
|
||||
|
||||
|
||||
def samples():
|
||||
return [
|
||||
{"name": "sine", "data": T.u8(T.synth("sine", 64, 64)), "volume": 64, "c2spd": 8363, "loop": (0, 64)},
|
||||
{"name": "square", "data": T.u8(T.synth("square", 64, 64, 0.5)), "volume": 40, "c2spd": 16726, "loop": (0, 64)},
|
||||
{"name": "saw", "data": T.u8(T.synth("saw", 100, 100, 0.6)), "volume": 64, "c2spd": 13000, "loop": (0, 100)},
|
||||
{"name": "noise", "data": T.u8(T.synth("noise", 6000, 1, 0.7, decay=1500)), "volume": 60, "c2spd": 8363},
|
||||
{"name": "tri", "data": T.u8(T.synth("tri", 50, 50, 0.8)), "volume": 50, "c2spd": 10000, "loop": (0, 50)},
|
||||
]
|
||||
|
||||
|
||||
def song_effects(keep=None):
|
||||
"""keep: debugging aid, a set of channels to keep (the others keep only their global effects)"""
|
||||
a, b, c = empty(4), empty(4), empty(4)
|
||||
mel = [61, 65, 68, 73, 68, 65, 63, 61]
|
||||
for i in range(16):
|
||||
put(a, i * 4, 0, mel[i % 8], 1, None, J if i % 4 == 1 else 0, 0x47 if i % 4 == 1 else 0)
|
||||
put(a, 0, 1, 49, 2, 48)
|
||||
put(a, 4, 1, 0, 0, None, D, 0x04)
|
||||
put(a, 8, 1, 0, 0, None, D, 0x20)
|
||||
put(a, 12, 1, 0, 0, None, D, 0xF2)
|
||||
put(a, 13, 1, 0, 0, None, D, 0x3F)
|
||||
put(a, 14, 1, 0, 0, None, D, 0x00)
|
||||
put(a, 16, 1, 51, 2, None, E, 0x03)
|
||||
put(a, 20, 1, 0, 0, None, F, 0x06)
|
||||
put(a, 24, 1, 0, 0, None, E, 0xF4)
|
||||
put(a, 25, 1, 0, 0, None, F, 0xE8)
|
||||
put(a, 28, 1, 56, 2, None, H, 0x46)
|
||||
put(a, 32, 1, 0, 0, None, U, 0x48)
|
||||
put(a, 36, 1, 0, 0, None, K, 0x02)
|
||||
put(a, 40, 1, 49, 2, None, G, 0x00)
|
||||
put(a, 41, 1, 61, 0, None, G, 0x10)
|
||||
put(a, 44, 1, 0, 0, None, L, 0x01)
|
||||
put(a, 48, 1, 54, 2, None, R, 0x58)
|
||||
put(a, 52, 1, 0, 0, None, I, 0x21)
|
||||
put(a, 56, 1, 0, 0, None, X, 0x20)
|
||||
put(a, 60, 1, 0, 0, None, S, 0x8C)
|
||||
for r in range(0, 64, 8):
|
||||
put(a, r, 3, 61, 4, 64 - r // 2)
|
||||
put(a, 20, 3, 0, 0, None, O, 0x08)
|
||||
put(a, 24, 3, 61, 4, None, Q, 0x83)
|
||||
put(a, 32, 3, 61, 4, None, S, 0xC3)
|
||||
put(a, 40, 3, 61, 4, None, S, 0xD2)
|
||||
put(a, 48, 2, 37, 3, None, V, 0x30)
|
||||
put(a, 56, 2, 0, 0, None, V, 0x40)
|
||||
put(b, 0, 2, 49, 3, None, A, 0x04)
|
||||
put(b, 4, 2, 0, 0, None, Tt, 0x90)
|
||||
put(b, 8, 2, 52, 5, None, S, 0xB0)
|
||||
put(b, 10, 0, 64, 1)
|
||||
put(b, 12, 2, 0, 0, None, S, 0xB2)
|
||||
put(b, 16, 2, 56, 5, None, S, 0xE2)
|
||||
put(b, 20, 0, 61, 1, None, O, 0x00)
|
||||
put(b, 24, 0, 254)
|
||||
put(b, 28, 2, 0, 0, None, C, 0x08)
|
||||
put(c, 8, 0, 49, 1, 32)
|
||||
put(c, 12, 1, 61, 2, None, X, 0x80)
|
||||
put(c, 16, 1, 0, 0, None, S, 0x82)
|
||||
put(c, 20, 0, 0, 0, None, B, 0x05)
|
||||
if keep is not None: # debugging: only some channels
|
||||
for p in (a, b, c):
|
||||
for row in p:
|
||||
for ch in range(4):
|
||||
if ch not in keep and row[ch][3] not in (A, B, C, Tt, V):
|
||||
row[ch] = (0, 0, None, 0, 0)
|
||||
return T.write_s3m("effects", samples(), [0, 1, 254, 2], [a, b, c], 4)
|
||||
|
||||
|
||||
def song_memory():
|
||||
"""ST3's shared effect memory, fast slides (ST3.00), the panning table, global volume, an order loop"""
|
||||
a = empty(6)
|
||||
put(a, 0, 0, 61, 1, None, D, 0x08)
|
||||
put(a, 4, 0, 0, 0, None, E, 0x02)
|
||||
put(a, 8, 0, 0, 0, None, D, 0x00)
|
||||
put(a, 12, 0, 0, 0, None, F, 0x00)
|
||||
put(a, 0, 1, 49, 3, None, D, 0x80)
|
||||
put(a, 2, 1, 0, 0, None, D, 0x00)
|
||||
put(a, 16, 2, 73, 5)
|
||||
put(a, 20, 2, 0, 0, None, Q, 0x02)
|
||||
put(a, 24, 2, 0, 0, None, Q, 0x00)
|
||||
put(a, 28, 3, 56, 2, 20)
|
||||
put(a, 28, 4, 63, 1, 30)
|
||||
put(a, 32, 5, 37, 3, None, X, 0x00)
|
||||
put(a, 40, 5, 0, 0, None, S, 0xE3)
|
||||
put(a, 48, 0, 0, 0, None, V, 0x20)
|
||||
put(a, 63, 0, 0, 0, None, B, 0x00)
|
||||
return T.write_s3m("memory", samples(), [0], [a], 6, speed=5, tempo=140, cwt=0x1300,
|
||||
pans=[2, 13, 5, 10, 7, 15], mvol=64 | 128, gvol=48)
|
||||
|
||||
|
||||
def song_mono():
|
||||
a = empty(2)
|
||||
put(a, 0, 0, 61, 1)
|
||||
put(a, 8, 1, 68, 2)
|
||||
put(a, 16, 0, 0, 0, None, H, 0x28)
|
||||
put(a, 32, 1, 0, 0, None, F, 0x10)
|
||||
return T.write_s3m("mono", samples(), [0], [a], 2, mvol=32)
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
cases = []
|
||||
for nm, data in (("effects", song_effects()), ("memory", song_memory()), ("mono", song_mono())):
|
||||
ref = T.reference(ctx, data, "s3m")
|
||||
cases.append({"name": nm, "data": data, "ref": ref, "duration": ref["duration"]})
|
||||
ctx.emit("s3m_cases", cases)
|
||||
@@ -0,0 +1,62 @@
|
||||
# debug only (not committed): one small module per effect, for locating engine differences against openmpt
|
||||
import os, sys
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import _tracker as T # noqa
|
||||
import s3m as S # noqa
|
||||
|
||||
def probes_s3m():
|
||||
out = []
|
||||
smp = S.samples()
|
||||
def one(nm, events, ch=1, **kw):
|
||||
p = S.empty(ch, 64)
|
||||
for e in events:
|
||||
S.put(p, *e)
|
||||
out.append((nm, T.write_s3m(nm, smp, [0], [p], ch, **kw), "s3m"))
|
||||
one("Q83", [(0, 0, 61, 4, None, S.Q, 0x83), (1, 0, 0, 0, None, S.Q, 0x83), (2, 0, 61, 4, None, S.Q, 0x83)])
|
||||
one("Q32", [(0, 0, 61, 4, None, S.Q, 0x32), (1, 0, 0, 0, None, S.Q, 0x00)])
|
||||
one("EF4", [(0, 0, 61, 2), (2, 0, 0, 0, None, S.E, 0xF4), (3, 0, 0, 0, None, S.F, 0xE8)])
|
||||
one("E03", [(0, 0, 61, 2), (2, 0, 0, 0, None, S.E, 0x03), (4, 0, 0, 0, None, S.F, 0x06)])
|
||||
one("D", [(0, 0, 61, 2, 48), (1, 0, 0, 0, None, S.D, 0x04), (3, 0, 0, 0, None, S.D, 0x20), (5, 0, 0, 0, None, S.D, 0xF2), (6, 0, 0, 0, None, S.D, 0x3F), (7, 0, 0, 0, None, S.D, 0x00)])
|
||||
one("H46", [(0, 0, 61, 1, None, S.H, 0x46), (1, 0, 0, 0, None, S.H, 0x00)])
|
||||
one("U48", [(0, 0, 61, 1, None, S.U, 0x48), (1, 0, 0, 0, None, S.U, 0x00)])
|
||||
one("K02", [(0, 0, 61, 1, None, S.H, 0x46), (1, 0, 0, 0, None, S.K, 0x02)])
|
||||
one("G", [(0, 0, 49, 1), (1, 0, 61, 0, None, S.G, 0x10), (3, 0, 49, 0, None, S.G, 0x00)])
|
||||
one("L01", [(0, 0, 49, 1), (1, 0, 61, 0, None, S.G, 0x08), (3, 0, 0, 0, None, S.L, 0x01)])
|
||||
one("R58", [(0, 0, 54, 1, None, S.R, 0x58), (1, 0, 0, 0, None, S.R, 0x00)])
|
||||
one("I21", [(0, 0, 54, 1, None, S.I, 0x21), (1, 0, 0, 0, None, S.I, 0x00)])
|
||||
one("J47", [(0, 0, 54, 1, None, S.J, 0x47), (1, 0, 0, 0, None, S.J, 0x00)])
|
||||
one("X", [(0, 0, 54, 1, None, S.X, 0x20), (4, 0, 0, 0, None, S.S, 0x8C), (8, 0, 0, 0, None, S.X, 0x80)])
|
||||
one("O", [(0, 0, 61, 4, None, S.O, 0x08), (4, 0, 61, 4, None, S.O, 0x00), (8, 0, 61, 4, None, S.O, 0x10)])
|
||||
one("SC", [(0, 0, 61, 4, None, S.S, 0xC3), (4, 0, 61, 1, None, S.S, 0xD2), (8, 0, 254)])
|
||||
one("V", [(0, 0, 61, 1, None, S.V, 0x30), (4, 0, 0, 0, None, S.V, 0x10)])
|
||||
one("T", [(0, 0, 61, 1, None, S.Tt, 0x90), (4, 0, 0, 0, None, S.A, 0x03)])
|
||||
one("SD2", [(0, 0, 61, 4), (8, 0, 61, 4, None, S.S, 0xD2), (16, 0, 61, 4, None, S.S, 0xD7)])
|
||||
one("G00mem", [(0, 0, 56, 2, None, S.H, 0x46), (4, 0, 0, 0, None, S.K, 0x02), (8, 0, 49, 2, None, S.G, 0x00), (9, 0, 61, 0, None, S.G, 0x10)])
|
||||
one("Qnote", [(0, 0, 61, 4), (4, 0, 61, 4, None, S.Q, 0x83), (5, 0, 0, 0, None, S.Q, 0x00), (8, 0, 61, 4, 64)])
|
||||
one("Gnew", [(0, 0, 49, 2, None, S.G, 0x04), (4, 0, 61, 0, None, S.G, 0x00)])
|
||||
one("seqA", [(24, 0, 61, 4, None, S.Q, 0x83), (32, 0, 61, 4, None, S.S, 0xC3), (48, 0, 61, 4, 40)])
|
||||
one("seqB", [(32, 0, 61, 4, None, S.S, 0xC3), (48, 0, 61, 4, 40)])
|
||||
one("seqC", [(24, 0, 61, 4, None, S.Q, 0x83), (48, 0, 61, 4, 40)])
|
||||
one("seqD", [(40, 0, 61, 4, None, S.S, 0xD2), (48, 0, 61, 4, 40)])
|
||||
base = [(r, 0, 61, 4, 64 - r // 2) for r in range(0, 64, 8)]
|
||||
one("b1", base)
|
||||
one("b2", base + [(20, 0, 0, 0, None, S.O, 0x08)])
|
||||
ev = base + [(20, 0, 0, 0, None, S.O, 0x08), (24, 0, 61, 4, None, S.Q, 0x83), (32, 0, 61, 4, None, S.S, 0xC3), (40, 0, 61, 4, None, S.S, 0xD2)]
|
||||
one("b3", ev)
|
||||
one("b4", base + [(24, 0, 61, 4, None, S.Q, 0x83), (32, 0, 61, 4, None, S.S, 0xC3), (40, 0, 61, 4, None, S.S, 0xD2)])
|
||||
one("v1", base + [(48, 1, 0, 0, None, S.V, 0x30), (56, 1, 0, 0, None, S.V, 0x40)], ch=2)
|
||||
one("v2", [(e[0], 1) + e[2:] for e in base] + [(48, 0, 0, 0, None, S.V, 0x30), (56, 0, 0, 0, None, S.V, 0x40)], ch=2)
|
||||
ev4 = [(e[0], 3) + e[2:] for e in base + [(24, 0, 61, 4, None, S.Q, 0x83), (32, 0, 61, 4, None, S.S, 0xC3), (40, 0, 61, 4, None, S.S, 0xD2)]]
|
||||
one("c1", ev4, ch=4)
|
||||
one("c2", ev4 + [(48, 2, 0, 0, None, S.V, 0x30)], ch=4)
|
||||
for keep in ((3,),):
|
||||
out.append(("eff" + "".join(map(str, keep)), S.song_effects(set(keep)), "s3m"))
|
||||
return out
|
||||
|
||||
def generate(ctx):
|
||||
which = os.environ.get("PROBE", "s3m")
|
||||
cases = []
|
||||
for nm, data, ext in {"s3m": probes_s3m}[which]():
|
||||
ref = T.reference(ctx, data, ext)
|
||||
cases.append({"name": nm, "data": data, "ref": ref, "duration": ref["duration"], "fmt": ext})
|
||||
ctx.emit("probe_cases", cases)
|
||||
Reference in new issue
Block a user