From 98b4ce533eac261eaab53f9e5593d88c8a889218 Mon Sep 17 00:00:00 2001 From: 4DBug Date: Sun, 1 Nov 2026 01:50:30 -0500 Subject: [PATCH] tests/music: comments: specs only --- tests/music/669.luau | 5 ++--- tests/music/_hively.luau | 5 +---- tests/music/_midivar.luau | 8 ++------ tests/music/_similar.luau | 17 ++++------------- tests/music/ahx.luau | 8 ++------ tests/music/far.luau | 5 ++--- tests/music/hmp.luau | 5 ++--- tests/music/hvl.luau | 8 ++------ tests/music/it.luau | 7 ++----- tests/music/med.luau | 5 ++--- tests/music/midi.luau | 14 +++----------- tests/music/mod.luau | 11 +++-------- tests/music/mtm.luau | 5 ++--- tests/music/mus.luau | 7 ++----- tests/music/okt.luau | 5 ++--- tests/music/ptm.luau | 5 ++--- tests/music/s3m.luau | 7 ++----- tests/music/sf2.luau | 13 ++----------- tests/music/stm.luau | 5 ++--- tests/music/ult.luau | 5 ++--- tests/music/umx.luau | 5 ++--- tests/music/xm.luau | 8 ++------ tests/music/xmi.luau | 5 ++--- 23 files changed, 49 insertions(+), 119 deletions(-) diff --git a/tests/music/669.luau b/tests/music/669.luau index 6717e40..953d8a7 100644 --- a/tests/music/669.luau +++ b/tests/music/669.luau @@ -1,6 +1,5 @@ --- music/669 tests: generated Composer 669 / UNIS 669 modules (tools/fixtures/669.py) parsed, rendered through --- codecs/audio/Tracker and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song --- length), the contract, and the fuzz no-throw pass. +-- music/669 tests: generated Composer 669 / UNIS 669 modules vs openmpt123's render. +-- Fixtures: tools/fixtures/669.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Six69 = require("@rosetta/music/669") diff --git a/tests/music/_hively.luau b/tests/music/_hively.luau index 93e5e09..dcf819c 100644 --- a/tests/music/_hively.luau +++ b/tests/music/_hively.luau @@ -1,12 +1,9 @@ --- tests/music/_hively: shared helper of the AHX / HVL tests (not a test itself): renders a fixture case through the --- format and compares it with hvl2wav's output exactly (16-bit samples: CRC-32 of the whole stream, the first --- differing frame located inside the raw head kept by tools/fixtures/ahx.py / hvl.py). +-- tests/music/_hively: shared helper of the AHX / HVL tests: exact against hvl2wav (CRC-32 of the 16-bit stream). local Bytes = require("@rosetta/core/Bytes") local Crc32 = require("@rosetta/core/Crc32") local H = {} --- check(t, Format, c): decode + render + exact comparison; returns the song function H.check(t: any, Format: any, c: any): any local song, err = Format.decode(Bytes.reader(buffer.fromstring(c.data))) t:check(song, c.name .. ": " .. tostring(err)) diff --git a/tests/music/_midivar.luau b/tests/music/_midivar.luau index 85c1a15..45f374b 100644 --- a/tests/music/_midivar.luau +++ b/tests/music/_midivar.luau @@ -1,7 +1,5 @@ --- tests/music/_midivar: shared helper of the MUS / XMI / HMP tests (not a test itself): compares a decoded Midi's --- channel events (codecs/audio/MidiRender.timeline: play order, seconds) with wildmidi -x's conversion --- (tools/fixtures/_midivar.py): notes on / off, program changes, pitch bends (MSB) and controllers, matched per --- (kind, channel, data) in time order, times within 0.1 ms + 1e-5 relative. +-- tests/music/_midivar: shared helper of the MUS / XMI / HMP tests: channel events against wildmidi -x's conversion +-- (tools/fixtures/_midivar.py), matched per (kind, channel, data) in time order, within 0.1 ms + 1e-5 relative. local Render = require("@rosetta/codecs/audio/MidiRender") local M = {} @@ -22,7 +20,6 @@ local function kindOf(status: number, d1: number, d2: number): string? return nil end --- the comparable events of a list of { seconds, status, d1, d2 }: key -> { seconds } local function index(list: { { number } }, opts: any): ({ [string]: { number } }, { [string]: number }) local by: { [string]: { number } }, counts: { [string]: number } = {}, {} for _, e in list do @@ -38,7 +35,6 @@ local function index(list: { { number } }, opts: any): ({ [string]: { number } } return by, counts end --- compare(t, midi, ref, label, opts?) -> worst time difference (s). opts.skip = { cc = true, ... } function M.compare(t: any, midi: any, ref: any, label: string, opts: any?): number local o = opts or {} local tl = Render.timeline(midi) diff --git a/tests/music/_similar.luau b/tests/music/_similar.luau index 2b5dc82..3933b47 100644 --- a/tests/music/_similar.luau +++ b/tests/music/_similar.luau @@ -1,6 +1,5 @@ --- tests/music/_similar: shared helper of the tracker tests (not a test itself): renders a module through a Decoder and --- compares it with a reference render's features (tools/fixtures/_tracker.py: per 2048-frame block the RMS of left, --- right and mid, and 40 log-spaced band magnitudes of mid from a Hann-windowed FFT). Same definitions on both sides. +-- tests/music/_similar: shared helper of the tracker tests: a render's features against a reference render's +-- (tools/fixtures/_tracker.py: per 2048-frame block the RMS of L / R / mid, 40 log bands of mid). Same definitions. local S = {} local SR, HOP, BANDS = 44100, 2048, 40 @@ -53,7 +52,6 @@ local function fft(re: { number }, im: { number }, n: number) end end --- features(samples (interleaved stereo f32 buffer), frames) -> { frames, rmsL, rmsR, rmsM, bands } function S.features(buf: buffer, frames: number): any local n = frames // HOP local out = { frames = n, rmsL = {}, rmsR = {}, rmsM = {}, bands = {} } @@ -88,7 +86,6 @@ function S.features(buf: buffer, frames: number): any return out end --- renderAll(decoder, maxFrames) -> interleaved buffer, frames function S.renderAll(dec: any, maxFrames: number): (buffer, number) local total = math.min(dec.frames, maxFrames) local out = buffer.create(math.max(1, total) * 8) @@ -109,7 +106,7 @@ local function db(x: number): number return 20 * math.log10(x + 1e-6) end --- compare(ours, ref) -> { gainDb, envCorr, spectral, balance } over the common frames: +-- compare(ours, ref) over the common frames: -- gainDb total mid energy ratio in dB (ours / ref) -- envCorr Pearson correlation of the per-block mid loudness in dB (blocks above -60 dB in either) -- envErr mean absolute difference of the per-block mid loudness in dB, after removing gainDb (same blocks) @@ -181,7 +178,6 @@ function S.compare(a: any, b: any): any } end --- worst(ours, ref, count) -> the blocks with the lowest spectral similarity (for debugging): { {block, sim} } function S.worst(a: any, b: any, count: number): { { number } } local list = {} for k = 1, math.min(a.frames, b.frames) do @@ -206,10 +202,7 @@ function S.worst(a: any, b: any, count: number): { { number } } return out end --- against(t, Fmt, cases, thresh, family?): the shared body of the tracker loader tests (ws-audio2: mtm, 669, stm, ult, --- okt, med, ptm, far, umx): each case decodes, sniffs, plays as long as openmpt's render (thresh.duration s) and --- matches its loudness / envelope / spectrum / balance within thresh; then a seek. cases: { name, data, ref, --- duration }. Returns the decoded modules. The tests run their fuzz pass with S.fuzzer / S.samples. +-- the shared body of the tracker loader tests: durations within thresh.duration s of openmpt's render function S.against(t: any, Fmt: any, cases: { any }, thresh: any, family: string?): { any } local Bytes = require("@rosetta/core/Bytes") local Tracker = require("@rosetta/codecs/audio/Tracker") @@ -256,7 +249,6 @@ function S.against(t: any, Fmt: any, cases: { any }, thresh: any, family: string return mods end --- fuzzer(Fmt) -> the fuzz function of a tracker loader: decode, and a short render of whatever decodes function S.fuzzer(Fmt: any): (buffer) -> any local Bytes = require("@rosetta/core/Bytes") local Tracker = require("@rosetta/codecs/audio/Tracker") @@ -272,7 +264,6 @@ function S.fuzzer(Fmt: any): (buffer) -> any end end --- samples(cases) -> the fuzz seeds (each case's data) function S.samples(cases: { any }): { string } local out = {} for _, c in cases do diff --git a/tests/music/ahx.luau b/tests/music/ahx.luau index 3adacfc..0270b63 100644 --- a/tests/music/ahx.luau +++ b/tests/music/ahx.luau @@ -1,7 +1,5 @@ --- music/ahx tests: AHX songs written by tools/fixtures/_hively.py (every waveform, filter and square sweeps, PList --- commands, effects, subsongs, AHX versions 0..2) and karma.ahx from the HivelyTracker source, rendered through --- codecs/audio/Hively and compared sample for sample with hvl2wav at several stereo separations and rates; the Module --- shape, bad input, and the fuzz no-throw pass. Fixtures: tools/fixtures/ahx.py. +-- music/ahx tests: AHX songs (tools/fixtures/_hively.py, karma.ahx) rendered by codecs/audio/Hively vs hvl2wav. +-- Fixtures: tools/fixtures/ahx.py. local T = require("@tests/T") local H = require("@tests/music/_hively") local Ahx = require("@rosetta/music/ahx") @@ -30,7 +28,6 @@ for _, c in Cases do t:eq(song.patterns[2].rows, 16, "track rows") t:eq(buffer.readu8(song.patterns[2].data, 0), 25, "track 1 row 0 note") t:eq(#song.subsongs, 1, "subsongs") - -- seek back and read again: the same samples local dec = song:render() local a = dec:read(4410) dec:seek(0.5) @@ -43,7 +40,6 @@ for _, c in Cases do end end --- bad input local function code(s: string): string? local _, e = Ahx.decode(Bytes.reader(buffer.fromstring(s))) return e and e.code diff --git a/tests/music/far.luau b/tests/music/far.luau index 0313c54..47fd345 100644 --- a/tests/music/far.luau +++ b/tests/music/far.luau @@ -1,6 +1,5 @@ --- music/far tests: generated Farandole Composer modules (tools/fixtures/far.py) parsed, rendered through --- codecs/audio/Tracker and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song --- length), the contract, and the fuzz no-throw pass. +-- music/far tests: generated Farandole Composer modules vs openmpt123's render. +-- Fixtures: tools/fixtures/far.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Far = require("@rosetta/music/far") diff --git a/tests/music/hmp.luau b/tests/music/hmp.luau index a4ad666..b845ddc 100644 --- a/tests/music/hmp.luau +++ b/tests/music/hmp.luau @@ -1,6 +1,5 @@ --- music/hmp tests: HMP (old and "013195" headers, several tick rates) and HMI files (tools/fixtures/hmp.py) decoded and --- compared with wildmidi -x's conversion (notes, HMI note durations, programs, bends, controllers), the FE / loop --- events skipped, a render, bad input, and the fuzz no-throw pass. +-- music/hmp tests: HMP and HMI files against wildmidi -x's conversion. +-- Fixtures: tools/fixtures/hmp.py. local T = require("@tests/T") local V = require("@tests/music/_midivar") local Hmp = require("@rosetta/music/hmp") diff --git a/tests/music/hvl.luau b/tests/music/hvl.luau index 826acae..6950878 100644 --- a/tests/music/hvl.luau +++ b/tests/music/hvl.luau @@ -1,7 +1,5 @@ --- music/hvl tests: HVL songs written by tools/fixtures/_hively.py (4..8 channels, two effect columns, ring modulation, --- panning, mix gain / stereo from the file, subsongs) and songs from the HivelyTracker source, rendered through --- codecs/audio/Hively and compared sample for sample with hvl2wav (44.1 and 48 kHz); the Module shape, bad input, and --- the fuzz no-throw pass. Fixtures: tools/fixtures/hvl.py. +-- music/hvl tests: HVL songs (tools/fixtures/_hively.py, HivelyTracker's) rendered by codecs/audio/Hively vs hvl2wav. +-- Fixtures: tools/fixtures/hvl.py. local T = require("@tests/T") local H = require("@tests/music/_hively") local Hvl = require("@rosetta/music/hvl") @@ -32,7 +30,6 @@ for _, c in Cases do t:eq(song.patterns[2].rows, 16, "track rows") t:eq(buffer.readu8(song.patterns[2].data, 0), 25, "track 1 row 0 note") t:eq(#song.subsongs, 1, "subsongs") - -- seek back and read again: the same samples local dec = song:render() local a = dec:read(4410) dec:seek(0.5) @@ -45,7 +42,6 @@ for _, c in Cases do end end --- bad input local function code(s: string): string? local _, e = Hvl.decode(Bytes.reader(buffer.fromstring(s))) return e and e.code diff --git a/tests/music/it.luau b/tests/music/it.luau index e9f4f56..a938e03 100644 --- a/tests/music/it.luau +++ b/tests/music/it.luau @@ -1,6 +1,5 @@ --- music/it tests: generated Impulse Tracker modules (tools/fixtures/it.py) parsed, rendered through codecs/audio/Tracker and --- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/it tests: generated Impulse Tracker modules vs openmpt123's render. +-- Fixtures: tools/fixtures/it.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local It = require("@rosetta/music/it") @@ -54,7 +53,6 @@ for _, c in Cases do end end --- seek: the position after a seek and the output continuing do local m = load(Cases[1].data) local dec = m:render() @@ -65,7 +63,6 @@ do t:check(Tracker.duration(m) == dec.duration, "duration()") end --- the fuzz pass: decode, and a short render of whatever decodes local samples = {} for _, c in Cases do table.insert(samples, c.data) diff --git a/tests/music/med.luau b/tests/music/med.luau index bd76566..a973628 100644 --- a/tests/music/med.luau +++ b/tests/music/med.luau @@ -1,6 +1,5 @@ --- music/med tests: generated MED / OctaMED modules (tools/fixtures/med.py: MMD0, MMD1 with hold / decay and finetune, --- MMD2 with a play sequence, an IFF 3-octave sample) parsed, rendered through codecs/audio/Tracker and compared with openmpt123's render --- (loudness envelope, band spectrum, stereo balance, song length), the contract, and the fuzz no-throw pass. +-- music/med tests: generated MED / OctaMED modules vs openmpt123's render. +-- Fixtures: tools/fixtures/med.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Med = require("@rosetta/music/med") diff --git a/tests/music/midi.luau b/tests/music/midi.luau index 71894f8..6209df7 100644 --- a/tests/music/midi.luau +++ b/tests/music/midi.luau @@ -1,7 +1,5 @@ --- music/midi tests: SMF formats 0 / 1 / 2 + SMPTE + RMID parsed exactly as python mido parses them, mido's own files --- re-encoded byte for byte, round trips without running status, the tempo map against mido's message times and --- lengths, meta summaries, crafted bad files, truncation (lenient / strict), the fallback-synth render (duration, --- level, seek), and the fuzz no-throw pass (decode, and decode + a short render). Fixtures: tools/fixtures/midi.py. +-- music/midi tests: SMF files parsed exactly as python mido parses them; mido's own files re-encoded byte for byte. +-- Fixtures: tools/fixtures/midi.py. local T = require("@tests/T") local Midi = require("@rosetta/music/midi") local Bytes = require("@rosetta/core/Bytes") @@ -18,7 +16,6 @@ local function decode(data: any, opts: any?): (any, any) return Midi.decode(Bytes.reader(b), opts) end --- the contract t:eq(Midi.name, "midi", "name") t:eq(Midi.category, "music", "category") t:check(table.find(Midi.extensions, "mid") ~= nil, "extensions") @@ -108,7 +105,6 @@ for _, c in Cases do end t:note("%d files parse as mido parses them; mido's files re-encode byte for byte", #Cases) --- meta summaries do local m = decode(byName.format0.data) t:eq(m.tracks[1].name, "format zero", "track name") @@ -186,7 +182,6 @@ do t:eq(#m.tracks[1].events, 2, "the caller's events are not changed") end --- crafted bad files for _, c in Bad do local ok, m, err = pcall(decode, c.data) t:check(ok, c.name .. ": threw " .. tostring(m)) @@ -210,7 +205,6 @@ do t:check(l == nil and lerr.code == Err.LIMIT, "maxEvents: LIMIT") end --- render through the built-in waveform set do local song = decode(byName.song.data) local dec = song:render({ tail = 0.5 }) @@ -253,9 +247,8 @@ do end end t:check(same, "seek renders the same samples as reading through") - a:seek(0.25) -- backwards + a:seek(0.25) t:check(math.abs(a:position() - 0.25) < 1e-4, "seek backwards") - -- open = decode + render local o = Midi.open(Bytes.reader(buffer.fromstring(byName.song.data)), { sampleRate = 22050, tail = 0 }) t:check(o and o.sampleRate == 22050, "open: a Decoder at the asked rate") local bad, berr = Midi.render(song, { sampleRate = 5 }) @@ -264,7 +257,6 @@ do t:check(bs == nil and Err.is(bserr), "render: bad soundfont bytes") end --- the fuzz no-throw pass local samples = {} for _, c in Cases do if #c.data < 20000 then diff --git a/tests/music/mod.luau b/tests/music/mod.luau index e778ac6..7fc36e6 100644 --- a/tests/music/mod.luau +++ b/tests/music/mod.luau @@ -1,6 +1,5 @@ --- music/mod tests: generated ProTracker modules (tools/fixtures/mod.py) parsed, rendered through codecs/audio/Tracker and --- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the MOD writer's --- round trip, the contract, and the fuzz no-throw pass. +-- music/mod tests: generated ProTracker modules vs openmpt123's render. +-- Fixtures: tools/fixtures/mod.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Mod = require("@rosetta/music/mod") @@ -47,8 +46,7 @@ for _, c in Cases do t:eq(buffer.tostring(out :: buffer), c.data, c.name .. ": round trip bytes") end --- MOD -> XM: the converted module plays as long, and sounds alike (XM has no channel panning and uses FT2's NTSC --- Amiga clock, so only the duration and the band spectrum are compared) +-- MOD -> XM: only duration and band spectrum compared (XM has no channel panning, uses the FT2 NTSC Amiga clock) local Xm = require("@rosetta/music/xm") for _, c in Cases do local m = load(c.data) @@ -63,7 +61,6 @@ for _, c in Cases do t:check(r.spectral > 0.9, string.format("%s: xm spectrum %.3f", c.name, r.spectral)) end --- through the API: load sniffs the MOD, open gives a Decoder, save converts to XM, load(as audio) renders do local F = require("@rosetta") local m, err = F.load(Cases[1].data) @@ -75,7 +72,6 @@ do t:eq(F.saveString(m, { format = "mod" }), Cases[1].data, "F.saveString keeps the MOD bytes") end --- seek: the position after a seek and the output continuing do local m = load(Cases[1].data) local dec = m:render() @@ -108,7 +104,6 @@ do t:check(total == 240000 and math.abs(l.duration - dec.duration) < 0.01, "loop plays past the end") end --- the fuzz pass: decode, and a short render of whatever decodes local samples = {} for _, c in Cases do table.insert(samples, c.data) diff --git a/tests/music/mtm.luau b/tests/music/mtm.luau index 1e7c70e..ef1866f 100644 --- a/tests/music/mtm.luau +++ b/tests/music/mtm.luau @@ -1,6 +1,5 @@ --- music/mtm tests: generated MultiTracker modules (tools/fixtures/mtm.py) parsed, rendered through codecs/audio/Tracker --- and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/mtm tests: generated MultiTracker modules vs openmpt123's render. +-- Fixtures: tools/fixtures/mtm.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Mtm = require("@rosetta/music/mtm") diff --git a/tests/music/mus.luau b/tests/music/mus.luau index b785040..82fd86e 100644 --- a/tests/music/mus.luau +++ b/tests/music/mus.luau @@ -1,6 +1,5 @@ --- music/mus tests: Doom MUS files (tools/fixtures/mus.py) decoded and compared with wildmidi -x's conversion (notes, --- programs, pitch bend MSB, controllers; times at wildmidi's tick rate), system events / measure ends, the tick rate --- option, a render, bad input, and the fuzz no-throw pass. +-- music/mus tests: Doom MUS files against wildmidi -x's conversion (times at wildmidi's tick rate). +-- Fixtures: tools/fixtures/mus.py. local T = require("@tests/T") local V = require("@tests/music/_midivar") local Mus = require("@rosetta/music/mus") @@ -57,7 +56,6 @@ do t:eq(q.meta.length, p.meta.length, "measures: same length") end --- a render through the built-in waveforms do local m = assert(decode(Cases[1].data)) local dec = m:render({ sampleRate = 22050, tail = 0.2 }) @@ -70,7 +68,6 @@ do t:check(peak > 0.01, "render makes sound") end --- bad input local _, e1 = decode("MUS\x1a\1\0") t:eq(e1 and e1.code, Err.TRUNCATED, "short header") local _, e2 = decode("MUS\x1a\2\0\200\0\1\0\0\0\0\0\0\0") diff --git a/tests/music/okt.luau b/tests/music/okt.luau index e0882a6..4bfb232 100644 --- a/tests/music/okt.luau +++ b/tests/music/okt.luau @@ -1,6 +1,5 @@ --- music/okt tests: generated Oktalyzer modules (tools/fixtures/okt.py) parsed, rendered through codecs/audio/Tracker --- and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/okt tests: generated Oktalyzer modules vs openmpt123's render. +-- Fixtures: tools/fixtures/okt.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Okt = require("@rosetta/music/okt") diff --git a/tests/music/ptm.luau b/tests/music/ptm.luau index fd363c1..32dac33 100644 --- a/tests/music/ptm.luau +++ b/tests/music/ptm.luau @@ -1,6 +1,5 @@ --- music/ptm tests: generated PolyTracker modules (tools/fixtures/ptm.py) parsed, rendered through codecs/audio/Tracker --- and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/ptm tests: generated PolyTracker modules vs openmpt123's render. +-- Fixtures: tools/fixtures/ptm.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Ptm = require("@rosetta/music/ptm") diff --git a/tests/music/s3m.luau b/tests/music/s3m.luau index c3807b7..b9b523a 100644 --- a/tests/music/s3m.luau +++ b/tests/music/s3m.luau @@ -1,6 +1,5 @@ --- music/s3m tests: generated Scream Tracker 3 modules (tools/fixtures/s3m.py) parsed, rendered through codecs/audio/Tracker and --- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/s3m tests: generated Scream Tracker 3 modules vs openmpt123's render. +-- Fixtures: tools/fixtures/s3m.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local S3m = require("@rosetta/music/s3m") @@ -41,7 +40,6 @@ for _, c in Cases do t:check(r.balance < THRESH.balance, c.name .. ": stereo balance") end --- seek: the position after a seek and the output continuing do local m = load(Cases[1].data) local dec = m:render() @@ -52,7 +50,6 @@ do t:check(Tracker.duration(m) == dec.duration, "duration()") end --- the fuzz pass: decode, and a short render of whatever decodes local samples = {} for _, c in Cases do table.insert(samples, c.data) diff --git a/tests/music/sf2.luau b/tests/music/sf2.luau index 67932f3..6bef0fb 100644 --- a/tests/music/sf2.luau +++ b/tests/music/sf2.luau @@ -1,7 +1,5 @@ --- music/sf2 + codecs/audio/SoundFont tests: a self-made SF2 parsed (INFO, presets, sample headers, instruments, generator --- merging with preset / instrument global zones, 16-bit and sm24 samples), a test song rendered through it compared --- with FluidSynth's render (loudness envelope and per-segment band spectra by correlation, pitch peaks), bad files, --- the built-in fallback waveform set, and the fuzz no-throw pass. Fixtures: tools/fixtures/sf2.py. +-- music/sf2 + codecs/audio/SoundFont tests: a self-made SF2; a test song rendered through it vs FluidSynth. +-- Fixtures: tools/fixtures/sf2.py. local T = require("@tests/T") local Sf2 = require("@rosetta/music/sf2") local Midi = require("@rosetta/music/midi") @@ -16,14 +14,12 @@ local function reader(s: string): Bytes.Reader return Bytes.reader(buffer.fromstring(s)) end --- the contract t:eq(Sf2.name, "sf2", "name") t:eq(Sf2.category, "music", "category") t:check(Sf2.caps.decode and not Sf2.caps.encode, "caps") t:eq(Sf2.sniff(reader(Fx.sf2)), 1, "sniff") t:eq(Sf2.sniff(reader("RIFF\0\0\0\0WAVE")), 0, "sniff WAVE") --- parse local sf, err = Sf2.decode(reader(Fx.sf2)) t:check(sf, "decode: " .. tostring(err)) local E = Fx.expect @@ -93,7 +89,6 @@ do t:eq(buffer.len(sf.samples), (sf.sampleCount + 1) * 4, "samples: one pad sample") end --- ------------------------------------------------------------------------------------------------ vs FluidSynth local F = Fx.fluid local song = Midi.decode(reader(Fx.song)) t:check(song, "song decodes") @@ -134,7 +129,6 @@ local function pearson(a: { number }, b: { number }): number return sab / math.sqrt(saa * sbb + 1e-30) end --- in-place radix-2 FFT of re / im (1-based arrays of length n, a power of two) local function fft(re: { number }, im: { number }, n: number) local j = 0 for i = 0, n - 2 do @@ -248,7 +242,6 @@ for wi, w in F.windows do t:note("window %g-%g s: peak %.1f Hz (FluidSynth %.1f Hz)", w[1], w[2], hz, F.peaks[wi]) end --- ------------------------------------------------------------------------------------------------ bad files local function bad(data: string, code: string, label: string) local ok, v, e = pcall(Sf2.decode, reader(data)) t:check(ok, label .. ": threw " .. tostring(v)) @@ -265,7 +258,6 @@ t:check(lim2 == nil and lerr2.code == Err.LIMIT, "maxRegions: LIMIT") local p, perr = SoundFont.parse(42 :: any) t:check(p == nil and perr.code == Err.ARG, "parse: bad argument") --- ------------------------------------------------------------------------------------------------ fallback do local fb = SoundFont.fallback() t:eq(#fb.presets, 129, "fallback: 128 programs + a drum kit") @@ -310,7 +302,6 @@ do t:check(true, "out-of-range render requests are clipped") end --- the fuzz no-throw pass (parse, then a few notes through whatever parsed) t:fuzz("decode", function(b: buffer) local f = Sf2.decode(Bytes.reader(b)) if f then diff --git a/tests/music/stm.luau b/tests/music/stm.luau index eea0197..05eb641 100644 --- a/tests/music/stm.luau +++ b/tests/music/stm.luau @@ -1,6 +1,5 @@ --- music/stm tests: generated Scream Tracker 2 modules (tools/fixtures/stm.py) parsed, rendered through --- codecs/audio/Tracker and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song --- length), the contract, and the fuzz no-throw pass. +-- music/stm tests: generated Scream Tracker 2 modules vs openmpt123's render. +-- Fixtures: tools/fixtures/stm.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Stm = require("@rosetta/music/stm") diff --git a/tests/music/ult.luau b/tests/music/ult.luau index 63772aa..179bd55 100644 --- a/tests/music/ult.luau +++ b/tests/music/ult.luau @@ -1,6 +1,5 @@ --- music/ult tests: generated UltraTracker modules (tools/fixtures/ult.py) parsed, rendered through codecs/audio/Tracker --- and compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length), the contract, --- and the fuzz no-throw pass. +-- music/ult tests: generated UltraTracker modules vs openmpt123's render. +-- Fixtures: tools/fixtures/ult.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Ult = require("@rosetta/music/ult") diff --git a/tests/music/umx.luau b/tests/music/umx.luau index 5437288..d39dc91 100644 --- a/tests/music/umx.luau +++ b/tests/music/umx.luau @@ -1,6 +1,5 @@ --- music/umx tests: Unreal packages wrapping generated S3M / IT modules (tools/fixtures/umx.py): the export found and --- unwrapped (bytes equal to the module put in), loaded through the api's decodeModule hook and rendered like --- openmpt123 renders the package, UNSUPPORTED without the hook, the contract, and the fuzz no-throw pass. +-- music/umx tests: Unreal packages wrapping generated S3M / IT modules, rendered like openmpt123 renders the package. +-- Fixtures: tools/fixtures/umx.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local F = require("@rosetta") diff --git a/tests/music/xm.luau b/tests/music/xm.luau index a224314..f81805e 100644 --- a/tests/music/xm.luau +++ b/tests/music/xm.luau @@ -1,7 +1,5 @@ --- music/xm tests: generated FastTracker 2 modules (tools/fixtures/xm.py) parsed, rendered through codecs/audio/Tracker and --- compared with openmpt123's render (loudness envelope, band spectrum, stereo balance, song length; a ModPlug ADPCM --- sample), the XM writer's --- round trip, the contract, and the fuzz no-throw pass. +-- music/xm tests: generated FastTracker 2 modules vs openmpt123's render. +-- Fixtures: tools/fixtures/xm.py. local T = require("@tests/T") local S = require("@tests/music/_similar") local Xm = require("@rosetta/music/xm") @@ -53,7 +51,6 @@ for _, c in Cases do end end --- seek: the position after a seek and the output continuing do local m = load(Cases[1].data) local dec = m:render() @@ -64,7 +61,6 @@ do t:check(Tracker.duration(m) == dec.duration, "duration()") end --- the fuzz pass: decode, and a short render of whatever decodes local samples = {} for _, c in Cases do table.insert(samples, c.data) diff --git a/tests/music/xmi.luau b/tests/music/xmi.luau index c787a6e..3d6889c 100644 --- a/tests/music/xmi.luau +++ b/tests/music/xmi.luau @@ -1,6 +1,5 @@ --- music/xmi tests: XMIDI files (tools/fixtures/xmi.py: XDIR + CAT XMID with one or two songs, a bare FORM XMID, with --- and without TIMB) decoded and compared with wildmidi -x's conversion of song 1 (notes from durations, programs, --- bends, controllers; 120 Hz), song selection, export to SMF, a render, bad input, and the fuzz no-throw pass. +-- music/xmi tests: XMIDI files against wildmidi -x's conversion of song 1 (120 Hz). +-- Fixtures: tools/fixtures/xmi.py. local T = require("@tests/T") local V = require("@tests/music/_midivar") local Xmi = require("@rosetta/music/xmi")