ws-audio2: api renderMusic uses a Module's own render method for non-tracker engines (AHX / HVL); docs/guide/music.md: AHX / HVL and MIDI variants section, Formats rows (docs inputs: tools/fixtures/docs_chip.py)

src/Formats/init.luau: renderMusic: a kind "music" value whose format is not mod/s3m/xm/it and that has a render
method renders through it (a failed render's .err becomes the error). Backward compatible.
This commit is contained in:
4DBug committed 2026-10-31 14:32:05 -05:00
1 parent 71bb89763e
commit d3ea84bb57
4 files changed
+126 -1

No files matched your search

+10 -1
View File
@@ -479,8 +479,10 @@ local function videoToImage(v: any, o: Options): (any, Err.Err?)
return img, nil
end
-- renderMusic(value, opts) -> the audio Decoder of a Module (codecs/audio/Tracker) or a Midi (music/midi render) |
-- renderMusic(value, opts) -> the audio Decoder of a Module (codecs/audio/Tracker, or the Module's own render method
-- for other engines) or a Midi (music/midi render) |
-- nil, Err. opts are the render options: sampleRate, soundfont, gain, tail, interpolation, stereoSeparation, ...
local TRACKER_FAMILY = { mod = true, s3m = true, xm = true, it = true }
local function renderMusic(value: any, o: Options): (any, Err.Err?)
local ok, dec, err
if value.kind == "midi" then
@@ -489,6 +491,13 @@ local function renderMusic(value: any, o: Options): (any, Err.Err?)
return nil, merr
end
ok, dec, err = pcall(m.render, value, o)
elseif TRACKER_FAMILY[value.format] == nil and type(value.render) == "function" then
-- a Module with its own engine (AHX / HVL: codecs/audio/Hively): its render method (a failed render is an
-- empty Decoder carrying .err)
ok, dec = pcall(value.render, value, o)
if ok and type(dec) == "table" and dec.err then
return nil, dec.err
end
else
local Tracker: any = require("@formats/codecs/audio/Tracker")
ok, dec, err = pcall(Tracker.render, value, o)