ws-audio2: music/xm decodes ModPlug ADPCM samples (were silence), through codecs/audio/Adpcm.modplug

Fixture: tools/fixtures/_tracker.py write_xm gains an optional per-sample "adpcm" payload (two lines, shared with
the tracker generators, backward compatible); a new xm case renders the same as openmpt123.
This commit is contained in:
4DBug committed 2026-10-31 14:37:23 -05:00
1 parent 2717292366
commit 9466c5f471
7 files changed
+96 -13

No files matched your search

+19
View File
@@ -72,6 +72,22 @@ do
t:check(z1 == 0 and z2 == 0, "adx coefs of rate 0")
end
-- ModPlug ADPCM: deltas from the table, wrapping as a signed byte
do
local src = buffer.create(18)
for k = 0, 15 do
buffer.writei8(src, k, if k == 1 then 100 elseif k == 2 then -3 else 0)
end
buffer.writeu8(src, 16, 0x11) -- +100, +100 (wraps to -56)
buffer.writeu8(src, 17, 0x02) -- -3, +0
local out = buffer.create(16)
Adpcm.modplug(src, 0, 4, out, 0)
local want = { 100, -56, -59, -59 }
for i, v in want do
t:eq(buffer.readf32(out, (i - 1) * 4) * 128, v, "modplug sample " .. i)
end
end
-- ------------------------------------------------------------------------------------------------ encoders
local function snr(x: buffer, y: buffer, count: number): number
local sig, err = 0, 0
@@ -216,6 +232,9 @@ t:fuzz("kernels", function(b: buffer)
if n >= 1 then
Adpcm.ima(b, 0, 0, 1, math.min(n * 2, 1000), true, st, 32, out, 0, 1)
end
if n >= 17 then
Adpcm.modplug(b, 0, math.min((n - 16) * 2, 1000), out, 0)
end
Adpcm.imaWav(b, 0, n, 2, 1017, buffer.create(1017 * 2 * 4), 0)
Adpcm.msBlock(b, 0, n, 2, 1012, buffer.create(1012 * 2 * 4), 0, coefs, 8, buffer.create(40))
local dec = Decoder.interleaved({ sampleRate = 8000, channels = 2, tags = {} }, { kind = "adx", buf = b, offset = 0, size = n, interleave = 18, c1 = 7334, c2 = -3283 })