ws-music: tracker seek / loop tests
This commit is contained in:
1 parent
7754646a86
commit
4b5194f343
1 file changed
+22
@@ -84,6 +84,28 @@ do
|
||||
local _, n = dec:read(1000)
|
||||
t:eq(n, 1000, "read after seek")
|
||||
t:check(Tracker.duration(m) == dec.duration, "duration()")
|
||||
-- the same samples as playing up to that point (after the short fade-in that follows a seek)
|
||||
local a, b = m:render(), m:render()
|
||||
a:seek(3.5)
|
||||
local at = math.floor(3.5 * S.SR)
|
||||
while at > 0 do
|
||||
local _, n = b:read(math.min(at, 8192))
|
||||
at -= n
|
||||
end
|
||||
local x, y = a:read(4096), b:read(4096)
|
||||
local worst = 0
|
||||
for i = 256, 4095 * 2 do
|
||||
worst = math.max(worst, math.abs(buffer.readf32(x, i * 4) - buffer.readf32(y, i * 4)))
|
||||
end
|
||||
t:check(worst < 1e-4, "seek then read matches reading through (" .. worst .. ")")
|
||||
-- loop = true keeps playing past the end (frames / duration still give one pass)
|
||||
local l = m:render({ loop = true, sampleRate = 8000 })
|
||||
local total = 0
|
||||
for _ = 1, 30 do
|
||||
local _, n = l:read(8000)
|
||||
total += n
|
||||
end
|
||||
t:check(total == 240000 and l.duration == dec.duration, "loop plays past the end")
|
||||
end
|
||||
|
||||
-- the fuzz pass: decode, and a short render of whatever decodes
|
||||
|
||||
Reference in new issue
Block a user