ws-music: music/it read + render (IT 2.14/2.15 decompression, NNA, filters, pitch-pan, OpenMPT note-fade coding), tracker tests tightened, MOD->XM + API checks, tracker bench lines, NOTICE
This commit is contained in:
1 parent
31f632f897
commit
3796ce674d
14 files changed
+964
-28
No files matched your search
@@ -116,3 +116,59 @@ do
|
||||
end
|
||||
print(string.format("%-8s %-30s %8.2f ms %7.1f M voice-samples/s", runtime, "synth 32 voices x 2 s", best * 1000, 32 * frames / best / 1e6))
|
||||
end
|
||||
-- the tracker engine: 32 channels of looped samples (one note each, linear interpolation, volume ramps), and an
|
||||
-- IT-style module with background voices (NNA continue) and resonant filters on every channel
|
||||
do
|
||||
local Tracker = require("@formats/codecs/Tracker")
|
||||
local function song(format: string, filter: boolean): any
|
||||
local m = Tracker.newModule(format, 32)
|
||||
m.order = { 0 }
|
||||
m.patterns[1] = Tracker.newPattern(64, 32)
|
||||
local s = Tracker.newSample("saw")
|
||||
s.length = 1000
|
||||
s.data = buffer.create(4000)
|
||||
for i = 0, 999 do
|
||||
buffer.writef32(s.data, i * 4, (i % 100) / 50 - 1)
|
||||
end
|
||||
s.loopStart, s.loopEnd, s.loopType = 0, 1000, 1
|
||||
m.samples[1] = s
|
||||
if format == "it" then
|
||||
local ins = Tracker.newInstrument("nna")
|
||||
for n = 1, 120 do
|
||||
ins.sampleMap[n] = 1
|
||||
end
|
||||
ins.nna = 1
|
||||
ins.fadeout = 64
|
||||
if filter then
|
||||
ins.cutoff, ins.resonance = 60, 40
|
||||
end
|
||||
m.instruments[1] = ins
|
||||
end
|
||||
for ch = 1, 32 do
|
||||
for row = 0, 63, 16 do
|
||||
Tracker.setCell(m, 0, row, ch, 37 + ch + row // 16, 1, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
return m
|
||||
end
|
||||
local function realtime(label: string, m: any, voices: number)
|
||||
local best, frames = math.huge, 0
|
||||
local out = buffer.create(4096 * 8)
|
||||
for _ = 1, 3 do
|
||||
local dec = Tracker.render(m) :: any
|
||||
frames = 0
|
||||
local t0 = os.clock()
|
||||
while true do
|
||||
local _, n = dec:read(4096, out)
|
||||
if n == 0 then
|
||||
break
|
||||
end
|
||||
frames += n
|
||||
end
|
||||
best = math.min(best, os.clock() - t0)
|
||||
end
|
||||
print(string.format("%-8s %-30s %8.2f ms %7.1f x realtime %5.1f M voice-samples/s", runtime, label, best * 1000, frames / 44100 / best, voices * frames / best / 1e6))
|
||||
end
|
||||
realtime("tracker 32 ch (mod)", song("mod", false), 32)
|
||||
realtime("tracker 32 ch + NNA, filters", song("it", true), 64)
|
||||
end
|
||||
Reference in new issue
Block a user