ws-audio2: merge ws/audio2-tracker (MTM, 669, STM, ULT, OKT, MED, PTM, FAR, UMX; Tracker engine families)
This commit is contained in:
commit
270eccab0f
43 files changed
+4907
-65
No files matched your search
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Six69 = require("@formats/music/669")
|
||||
local Cases = require("@tests/gen/669_cases")
|
||||
|
||||
local t = T.suite("669")
|
||||
|
||||
t:eq(Six69.name, "669", "name")
|
||||
t:eq(Six69.category, "music", "category")
|
||||
t:check(Six69.caps.decode and not Six69.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Six69, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "s3m")
|
||||
t:check(mods[2] and mods[2].meta.source.tracker == "UNIS 669", "UNIS 669")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Six69), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -206,4 +206,79 @@ 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.
|
||||
function S.against(t: any, Fmt: any, cases: { any }, thresh: any, family: string?): { any }
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Tracker = require("@formats/codecs/audio/Tracker")
|
||||
local mods = {}
|
||||
for _, c in cases do
|
||||
local m, err = Fmt.decode(Bytes.reader(buffer.fromstring(c.data)))
|
||||
t:check(m, c.name .. ": " .. tostring(err))
|
||||
if not m then
|
||||
continue
|
||||
end
|
||||
table.insert(mods, m)
|
||||
t:eq(m.format, Fmt.name, c.name .. ": format")
|
||||
if family then
|
||||
t:eq(Tracker.family(m), family, c.name .. ": engine family")
|
||||
end
|
||||
t:check(Fmt.sniff(Bytes.reader(buffer.fromstring(c.data))) > 0, c.name .. ": sniff")
|
||||
local dec = m:render({ sampleRate = S.SR })
|
||||
t:check(dec, c.name .. ": render")
|
||||
t:check(math.abs(dec.duration - c.duration) < thresh.duration, string.format("%s: duration %.3f s, openmpt %.3f s", c.name, dec.duration, c.duration))
|
||||
local buf, frames = S.renderAll(dec, math.floor(c.duration * S.SR))
|
||||
local f = S.features(buf, frames)
|
||||
local r = S.compare(f, c.ref)
|
||||
t:note("%-8s gain %+.2f dB, loudness error %.2f dB, spectrum %.3f, balance %.3f, %.2f s", c.name, r.gainDb, r.envErr, r.spectral, r.balance, dec.duration)
|
||||
if r.spectral < thresh.spectral or r.envErr > thresh.envErr then
|
||||
for _, w in S.worst(f, c.ref, 6) do
|
||||
t:note(" block %d (%.2f s): spectrum %.3f, ours %.1f dB, ref %.1f dB", w[1], (w[1] - 1) * 2048 / S.SR, w[2], w[3], w[4])
|
||||
end
|
||||
end
|
||||
t:check(math.abs(r.gainDb) < thresh.gainDb, c.name .. ": loudness")
|
||||
t:check(r.envErr < thresh.envErr, c.name .. ": loudness envelope")
|
||||
t:check(r.spectral > thresh.spectral, c.name .. ": spectrum")
|
||||
t:check(r.balance < thresh.balance, c.name .. ": stereo balance")
|
||||
end
|
||||
-- seek: the position after a seek and the output continuing
|
||||
local m = mods[1]
|
||||
if m then
|
||||
local dec = m:render()
|
||||
dec:seek(1)
|
||||
t:check(math.abs(dec:position() - 1) < 0.001, "seek position")
|
||||
local _, n = dec:read(1000)
|
||||
t:eq(n, 1000, "read after seek")
|
||||
t:check(Tracker.duration(m) == dec.duration, "duration()")
|
||||
end
|
||||
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("@formats/core/Bytes")
|
||||
local Tracker = require("@formats/codecs/audio/Tracker")
|
||||
return function(b: buffer): any
|
||||
local fm = Fmt.decode(Bytes.reader(b))
|
||||
if fm then
|
||||
local d = Tracker.render(fm, { maxDuration = 0.5, sampleRate = 8000 })
|
||||
if d then
|
||||
d:read(4000)
|
||||
end
|
||||
end
|
||||
return fm
|
||||
end
|
||||
end
|
||||
|
||||
-- samples(cases) -> the fuzz seeds (each case's data)
|
||||
function S.samples(cases: { any }): { string }
|
||||
local out = {}
|
||||
for _, c in cases do
|
||||
table.insert(out, c.data)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
return S
|
||||
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Far = require("@formats/music/far")
|
||||
local Cases = require("@tests/gen/far_cases")
|
||||
|
||||
local t = T.suite("far")
|
||||
|
||||
t:eq(Far.name, "far", "name")
|
||||
t:eq(Far.category, "music", "category")
|
||||
t:check(Far.caps.decode and not Far.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Far, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "s3m")
|
||||
t:check(mods[1] and mods[1].patterns[2].rows == 48 and mods[1].channelMute[10], "pattern length, muted channel")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Far), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,22 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Med = require("@formats/music/med")
|
||||
local Cases = require("@tests/gen/med_cases")
|
||||
|
||||
local t = T.suite("med")
|
||||
|
||||
t:eq(Med.name, "med", "name")
|
||||
t:eq(Med.category, "music", "category")
|
||||
t:check(Med.caps.decode and not Med.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Med, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "xm")
|
||||
t:check(mods[2] and mods[2].instrumentMode and mods[2].instruments[1].volEnv ~= nil, "MMD1 hold / decay: an instrument envelope")
|
||||
t:check(mods[2] and mods[2].title == "med test", "song name")
|
||||
t:check(mods[3] and mods[3].channels == 6 and mods[3].meta.source.version == "MMD2", "MMD2")
|
||||
t:check(mods[4] and mods[4].instrumentMode and #mods[4].samples == 4 and mods[4].samples[3].length == 128, "IFF 3-octave sample")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Med), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,20 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Mtm = require("@formats/music/mtm")
|
||||
local Cases = require("@tests/gen/mtm_cases")
|
||||
|
||||
local t = T.suite("mtm")
|
||||
|
||||
t:eq(Mtm.name, "mtm", "name")
|
||||
t:eq(Mtm.category, "music", "category")
|
||||
t:check(Mtm.caps.decode and not Mtm.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Mtm, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "xm")
|
||||
t:check(mods[1] and #mods[1].samples == 5 and mods[1].samples[3].bits == 16, "16-bit sample")
|
||||
t:check(mods[1] and mods[1].meta.message ~= nil, "message")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Mtm), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Okt = require("@formats/music/okt")
|
||||
local Cases = require("@tests/gen/okt_cases")
|
||||
|
||||
local t = T.suite("okt")
|
||||
|
||||
t:eq(Okt.name, "okt", "name")
|
||||
t:eq(Okt.category, "music", "category")
|
||||
t:check(Okt.caps.decode and not Okt.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Okt, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "it")
|
||||
t:check(mods[2] and mods[2].channels == 6, "two mixed pairs: 6 channels")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Okt), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Ptm = require("@formats/music/ptm")
|
||||
local Cases = require("@tests/gen/ptm_cases")
|
||||
|
||||
local t = T.suite("ptm")
|
||||
|
||||
t:eq(Ptm.name, "ptm", "name")
|
||||
t:eq(Ptm.category, "music", "category")
|
||||
t:check(Ptm.caps.decode and not Ptm.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Ptm, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "it")
|
||||
t:check(mods[1] and mods[1].samples[3].bits == 16 and mods[1].samples[3].loopType == 2, "16-bit ping-pong loop")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Ptm), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Stm = require("@formats/music/stm")
|
||||
local Cases = require("@tests/gen/stm_cases")
|
||||
|
||||
local t = T.suite("stm")
|
||||
|
||||
t:eq(Stm.name, "stm", "name")
|
||||
t:eq(Stm.category, "music", "category")
|
||||
t:check(Stm.caps.decode and not Stm.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Stm, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "s3m")
|
||||
t:check(mods[1] and mods[1].meta.source.tracker == "!Scream!", "tracker name")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Stm), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,19 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local Ult = require("@formats/music/ult")
|
||||
local Cases = require("@tests/gen/ult_cases")
|
||||
|
||||
local t = T.suite("ult")
|
||||
|
||||
t:eq(Ult.name, "ult", "name")
|
||||
t:eq(Ult.category, "music", "category")
|
||||
t:check(Ult.caps.decode and not Ult.caps.encode, "caps")
|
||||
|
||||
local mods = S.against(t, Ult, Cases, { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }, "it")
|
||||
t:check(mods[1] and mods[1].samples[3].bits == 16 and mods[1].samples[3].susType == 2, "16-bit ping-pong sustain loop")
|
||||
|
||||
t:fuzz("decode", S.fuzzer(Ult), S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
@@ -0,0 +1,51 @@
|
||||
-- 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.
|
||||
local T = require("@tests/T")
|
||||
local S = require("@tests/music/_similar")
|
||||
local F = require("@formats")
|
||||
local Umx = require("@formats/music/umx")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Cases = require("@tests/gen/umx_cases")
|
||||
|
||||
local t = T.suite("umx")
|
||||
|
||||
t:eq(Umx.name, "umx", "name")
|
||||
t:eq(Umx.category, "music", "category")
|
||||
t:check(Umx.caps.decode and not Umx.caps.encode, "caps")
|
||||
|
||||
local THRESH = { gainDb = 0.5, envErr = 1.0, spectral = 0.95, balance = 0.04, duration = 0.01 }
|
||||
local function hook(b: buffer, format: string?): (any, any)
|
||||
return F.load(b, { category = "music", format = format })
|
||||
end
|
||||
|
||||
for _, c in Cases do
|
||||
local r = Bytes.reader(buffer.fromstring(c.data))
|
||||
t:check(Umx.sniff(r) == 1, c.name .. ": sniff")
|
||||
local list = Umx.extract(r)
|
||||
t:check(list and #list == 1 and list[1].name == string.lower(c.name) and list[1].format == c.format, c.name .. ": extract")
|
||||
t:eq(list and buffer.tostring(list[1].data), c.inner, c.name .. ": the embedded module's bytes")
|
||||
local _, err = Umx.decode(Bytes.reader(buffer.fromstring(c.data)))
|
||||
t:check(err and err.code == F.Err.UNSUPPORTED, c.name .. ": no hook: UNSUPPORTED")
|
||||
local m, merr = Umx.decode(Bytes.reader(buffer.fromstring(c.data)), { decodeModule = hook })
|
||||
t:check(m and m.format == c.format and m.meta.container.format == "umx", c.name .. ": decode " .. tostring(merr))
|
||||
local viaApi = F.load(c.data)
|
||||
t:check(viaApi and viaApi.kind == "music" and viaApi.meta.container and viaApi.meta.container.name == string.lower(c.name), c.name .. ": F.load")
|
||||
t:eq(F.detect(c.data), "umx", c.name .. ": F.detect")
|
||||
local dec = m:render({ sampleRate = S.SR })
|
||||
t:check(math.abs(dec.duration - c.duration) < THRESH.duration, string.format("%s: duration %.3f s, openmpt %.3f s", c.name, dec.duration, c.duration))
|
||||
local buf, frames = S.renderAll(dec, math.floor(c.duration * S.SR))
|
||||
local res = S.compare(S.features(buf, frames), c.ref)
|
||||
t:note("%-10s gain %+.2f dB, loudness error %.2f dB, spectrum %.3f, balance %.3f, %.2f s", c.name, res.gainDb, res.envErr, res.spectral, res.balance, dec.duration)
|
||||
t:check(math.abs(res.gainDb) < THRESH.gainDb and res.envErr < THRESH.envErr, c.name .. ": loudness")
|
||||
t:check(res.spectral > THRESH.spectral and res.balance < THRESH.balance, c.name .. ": spectrum, balance")
|
||||
local d2 = F.open(c.data)
|
||||
t:check(d2 and d2.channels == 2, c.name .. ": F.open renders")
|
||||
end
|
||||
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
local m = Umx.decode(Bytes.reader(b), { decodeModule = hook })
|
||||
Umx.extract(Bytes.reader(b))
|
||||
return m
|
||||
end, S.samples(Cases), { mutations = 30 })
|
||||
t:done()
|
||||
Reference in new issue
Block a user