27 lines
1.5 KiB
Python
27 lines
1.5 KiB
Python
# XMIDI fixtures (tools/fixtures.py): XMI files written by tools/fixtures/_midivar.py (FORM XDIR + CAT XMID with one or
|
|
# two songs, a bare FORM XMID (its reference converted from the same song with XDIR); every channel event, note durations, sysex, meta) and wildmidi -x's conversion of song 1
|
|
# as the reference event stream. Each song starts with a tempo event, as real files do (wildmidi derives its 120 Hz
|
|
# conversion from the first tempo event).
|
|
# tests/gen/xmi_cases.luau { { name, data, songs, ref = { division, tempo, events = { {seconds, status, d1, d2} } } } }
|
|
import importlib.util, os
|
|
|
|
INPUTS = ["tools/fixtures/_midivar.py"]
|
|
_spec = importlib.util.spec_from_file_location("_midivar", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_midivar.py"))
|
|
M = importlib.util.module_from_spec(_spec)
|
|
_spec.loader.exec_module(M)
|
|
|
|
|
|
def generate(ctx):
|
|
rng = ctx.rng(0x584D49)
|
|
cases = []
|
|
for i in range(4):
|
|
songs = [M.random_xmi_song(rng, n=60 + 40 * i, tempo=rng.choice([500000, 1000000, 400000]))]
|
|
if i == 1:
|
|
songs.append(M.random_xmi_song(rng, n=20, tempo=500000))
|
|
data = M.write_xmi(songs, timb=(i != 3))
|
|
ref = M.wildmidi(ctx, data, "xmi")
|
|
if i == 2:
|
|
data = M.write_xmi(songs, with_xdir=False) # a bare FORM XMID (wildmidi wants XDIR: the reference comes from the full file)
|
|
cases.append({"name": "random %d" % i, "data": data, "songs": len(songs), "ref": ref})
|
|
ctx.emit("xmi_cases", cases)
|