# FAR fixtures (tools/fixtures.py): generated Farandole Composer modules exercising the effects, rendered by openmpt123. # tests/gen/far_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(rows=64): return [[(0, 0, 0, 0) for _ in range(16)] for _ in range(rows)] def put(p, row, ch, note=0, ins=0, vol=0, cmd=None, param=0): p[row][ch] = (note, ins, vol, 0 if cmd is None else (cmd << 4) | param) def samples(): return [ {"name": "sine", "data": T.s8(T.synth("sine", 64, 64)), "volume": 15, "loop": (0, 64)}, {"name": "square", "data": T.s8(T.synth("square", 64, 64, 0.5)), "volume": 11, "loop": (0, 64)}, {"name": "saw16", "data": T.s16(T.synth("saw", 200, 100, 0.6)), "bits": 16, "volume": 15, "loop": (0, 200)}, {"name": "noise", "data": T.s8(T.synth("noise", 6000, 1, 0.7, decay=1500)), "volume": 14}, {"name": "tri", "data": T.s8(T.synth("tri", 50, 50, 0.8)), "volume": 12, "loop": (0, 50)}, ] def song_effects(keep=None): a, b = empty(), empty(48) mel = [61, 65, 68, 73, 68, 65, 63, 61] for i in range(16): put(a, i * 4, 0, mel[i % 8], 1, 16 - i % 4) put(a, 0, 1, 49, 2, 12) put(a, 4, 1, 0, 0, 0, 0x1, 0x3) # fine porta up put(a, 8, 1, 0, 0, 0, 0x2, 0x5) put(a, 12, 1, 0, 0, 0, 0x8, 0x2) # volume slide down put(a, 16, 1, 51, 2, 14, 0x7, 0x1) # up put(a, 20, 1, 0, 0, 0, 0x5, 0x4) # vibrato depth put(a, 21, 1, 0, 0, 0, 0x6, 0x2) # vibrato speed put(a, 28, 1, 56, 2, 14) put(a, 32, 1, 61, 2, 0, 0x3, 0x4) # tone portamento (keeps going) put(a, 40, 1, 49, 2, 0, 0x3, 0x2) put(a, 48, 1, 0, 0, 0, 0xA, 0x8) # volume portamento for r in range(0, 64, 8): put(a, r, 3, 61, 4, 16 - r // 8) put(a, 36, 3, 61, 4, 16, 0x4, 0x2) # retrigger put(a, 4, 2, 37, 3, 12) put(a, 2, 4, 73, 5, 10, 0xB, 0x2) # panning put(a, 30, 4, 0, 0, 0, 0xB, 0xD) put(a, 10, 5, 56, 1, 12) put(a, 24, 5, 0, 0, 0, 0xF, 0x3) # speed put(b, 0, 0, 49, 1, 16) put(b, 8, 0, 61, 1, 16, 0x2, 0x8) put(b, 0, 2, 37, 3, 12) put(b, 16, 2, 44, 3, 10, 0x9, 0x3) put(b, 20, 6, 68, 5, 16) put(b, 24, 9, 56, 2, 16) # a muted channel if keep is not None: for p in (a, b): for row in p: for ch in range(16): if ch not in keep and (row[ch][3] >> 4) != 0xF: row[ch] = (0, 0, 0, 0) return T.write_far("effects", samples(), [0, 1], [a, b], speed=5, breaks=[0, 30], mute=(9,), pans=[3, 12, 7, 0, 15, 9, 5, 10, 8, 8, 8, 8, 8, 8, 8, 8], message=b"far test") def generate(ctx): cases = [] for nm, data in (("effects", song_effects()),): ref = T.reference(ctx, data, "far") cases.append({"name": nm, "data": data, "ref": ref, "duration": ref["duration"]}) ctx.emit("far_cases", cases)