# OKT fixtures (tools/fixtures.py): generated Oktalyzer modules exercising the effects and the mixed channel pairs, # rendered by openmpt123. # tests/gen/okt_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(ch, rows=64): return [[(0, 0, 0, 0) for _ in range(ch)] for _ in range(rows)] def put(p, row, ch, note=0, ins=0, fx=0, param=0): p[row][ch] = (note, ins, fx, param) def samples(): return [ {"name": "sine", "data": T.s8(T.synth("sine", 64, 64)), "volume": 64, "type": 2, "loop": (0, 64)}, {"name": "square", "data": T.s8(T.synth("square", 64, 64, 0.5)), "volume": 44, "type": 1, "loop": (0, 64)}, {"name": "saw", "data": T.s8(T.synth("saw", 128, 64, 0.6)), "volume": 64, "type": 0, "loop": (64, 64)}, {"name": "noise", "data": T.s8(T.synth("noise", 4000, 1, 0.7, decay=1200)), "volume": 60, "type": 2}, {"name": "tri", "data": T.s8(T.synth("tri", 32, 32, 0.8)), "volume": 52, "type": 2, "loop": (0, 32)}, ] def song_raw(keep=None): """four raw Paula channels: slides, arpeggios, note slides, volume, release""" a, b = empty(4), empty(4, 48) mel = [13, 17, 20, 25, 20, 17, 15, 13] for i in range(16): put(a, i * 4, 0, mel[i % 8], 1) put(a, 2, 0, 0, 0, 10, 0x37) # arpeggio 1 put(a, 10, 0, 0, 0, 11, 0x37) # arpeggio 2 put(a, 18, 0, 0, 0, 12, 0x37) # arpeggio 3 put(a, 0, 1, 1, 2) put(a, 4, 1, 0, 0, 1, 0x02) # period down (pitch up) put(a, 12, 1, 0, 0, 2, 0x03) put(a, 20, 1, 13, 2, 31, 0x20) # volume 0x20 put(a, 24, 1, 0, 0, 31, 0x43) # slide down put(a, 28, 1, 0, 0, 31, 0x52) # slide up put(a, 32, 1, 0, 0, 31, 0x64) # fine down put(a, 36, 1, 0, 0, 31, 0x76) # fine up put(a, 40, 1, 8, 2, 30, 0x01) # note slide up every tick put(a, 44, 1, 0, 0, 13, 0x02) put(a, 48, 1, 0, 0, 17, 0x03) # once put(a, 52, 1, 0, 0, 21, 0x05) for r in range(0, 64, 8): put(a, r, 3, 13, 4) put(a, 2, 2, 25, 5) put(a, 30, 2, 0, 0, 27, 0) # release: the sustain loop ends put(a, 36, 2, 1, 5) put(a, 34, 3, 0, 0, 28, 0x04) # speed put(b, 0, 0, 13, 1) put(b, 8, 1, 20, 2) put(b, 16, 2, 13, 3) # a paired-only sample on a raw channel: stops it put(b, 24, 3, 25, 5, 25, 0x00) # jump to 0 (song end) if keep is not None: for p in (a, b): for row in p: for ch in range(4): if ch not in keep and row[ch][2] not in (25, 28): row[ch] = (0, 0, 0, 0) return T.write_okt(samples(), [0, 1], [a, b], speed=6) def song_pairs(keep=None): """two mixed pairs (channels 2 / 3 and 5 / 6) and two raw channels""" a = empty(6) for r in range(0, 64, 4): put(a, r, 0, 13 + (r // 4) % 12, 1) put(a, r, 1, 1 + (r // 4) % 7, 3) put(a, r + 2, 2, 20, 1) put(a, 16, 1, 0, 0, 31, 0x30) # pair volume (shared) put(a, 32, 2, 0, 0, 31, 0x10) # the second channel's volume wins put(a, 40, 1, 0, 0, 31, 0x52) # pair volume slide put(a, 0, 3, 13, 2) put(a, 8, 4, 25, 4) put(a, 10, 5, 13, 5) put(a, 20, 5, 30, 1) # too high on a pair: clamped put(a, 48, 4, 13, 1, 31, 0x18) if keep is not None: for row in a: for ch in range(6): if ch not in keep: row[ch] = (0, 0, 0, 0) return T.write_okt(samples(), [0], [a], cmod=(1, 0, 1, 0), speed=5) def generate(ctx): cases = [] for nm, data in (("raw", song_raw()), ("pairs", song_pairs())): ref = T.reference(ctx, data, "okt") cases.append({"name": nm, "data": data, "ref": ref, "duration": ref["duration"]}) ctx.emit("okt_cases", cases)