ws-audio2: music/umx (Unreal music packages): the package tables parsed, the music export's module handed to a new api hook opts.decodeModule(buf, format?)
src/Formats/init.luau: withHooks adds opts.decodeModule (F.load of the bytes as music) next to decodeImage / openAudio, so a format never requires another; docs/API.md lists it. Backward compatible (a new optional hook).
This commit is contained in:
1 parent
3d5cf3130e
commit
26fa887370
8 files changed
+368
-1
No files matched your search
+10
-1
@@ -276,6 +276,9 @@ end
|
||||
-- the embedded parts) when called directly.
|
||||
-- They also see the injected plug-ins as opts.plugins (F.plugins: the B-rep kernel for cad/step) unless given their own.
|
||||
--
|
||||
-- Tracker modules inside other files (music/umx): opts.decodeModule(buf, format?) -> Module | nil, Err, the bytes loaded
|
||||
-- as music (sniffed, or as the given format).
|
||||
--
|
||||
-- Audio tracks of video containers: opts.openAudio(demuxer, track) -> audio Decoder | nil, Err. The track's packets
|
||||
-- become a stream an audio format reads (containers/AudioWrap: PCM -> WAV, Opus / Vorbis -> Ogg, AAC -> ADTS, MP3 /
|
||||
-- FLAC as they are), opened through F.open with that format.
|
||||
@@ -299,7 +302,7 @@ local function openAudio(demuxer: any, track: any): (any, Err.Err?)
|
||||
end
|
||||
|
||||
local function withHooks(o: Options): Options
|
||||
if o.decodeImage ~= nil and o.encodeImage ~= nil and o.plugins ~= nil and o.openAudio ~= nil then
|
||||
if o.decodeImage ~= nil and o.encodeImage ~= nil and o.plugins ~= nil and o.openAudio ~= nil and o.decodeModule ~= nil then
|
||||
return o
|
||||
end
|
||||
local c = table.clone(o)
|
||||
@@ -319,6 +322,12 @@ local function withHooks(o: Options): Options
|
||||
return F.save(img, nil, { format = format, category = "image" })
|
||||
end
|
||||
end
|
||||
if c.decodeModule == nil then
|
||||
-- tracker modules inside other files (music/umx: the module of an Unreal package), as their own format
|
||||
c.decodeModule = function(b: buffer, format: string?): (any, Err.Err?)
|
||||
return F.load(b, { category = "music", format = format })
|
||||
end
|
||||
end
|
||||
return c
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user