From 0d96b52b85e517d065be6c1cabdc2dcc63619f4c Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Tue, 2 Jul 2024 03:24:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E8=A1=A5=E5=85=85fmod?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=AF=AD=E6=B3=95=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/fmod20221/init.lua | 22 ++++++---------------- assets/fmod20221/wrap.lua | 30 +++++++++++++++++++++++------- assets/songbook.lua | 3 +++ main.lua | 11 ++++++----- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/assets/fmod20221/init.lua b/assets/fmod20221/init.lua index 12f15274..2eb81dd7 100644 --- a/assets/fmod20221/init.lua +++ b/assets/fmod20221/init.lua @@ -142,7 +142,8 @@ end -------------------------- ----@type table | fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? +---@class FMOD._Music +---@overload fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? M.music={} ---@param v number @@ -163,16 +164,6 @@ function M.music.getDesc(name) return musicLib[name] end ----Get event param description by name, to check if a param exists ----@param name string ----@param param string ----@return FMOD.Studio.ParamDescription? -function M.music.getParamDesc(name,param) - local desc=musicLib[name] - if not desc then return end - return (musicLib[name]:getParameterDescriptionByName(param)) -end - ---@param name string ---@param args? {instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table} ---@return FMOD.Studio.EventInstance? @@ -283,12 +274,12 @@ function M.music.getPlaying() return playing.event end -local playMusic=M.music.play -setmetatable(M.music,{__call=function(_,...) return playMusic(...) end}) +setmetatable(M.music,{__call=function(_,...) return M.music.play(...) end}) -------------------------- ----@type table | fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? +---@class FMOD._Effect +---@overload fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? M.effect={} ---@param v number @@ -401,8 +392,7 @@ function M.effect.stop(name,instant) end end -local playEffect=M.effect.play -setmetatable(M.effect,{__call=function(_,...) return playEffect(...) end}) +setmetatable(M.effect,{__call=function(_,...) return M.effect.play(...) end}) -------------------------- diff --git a/assets/fmod20221/wrap.lua b/assets/fmod20221/wrap.lua index 2af72d39..c8eb8657 100644 --- a/assets/fmod20221/wrap.lua +++ b/assets/fmod20221/wrap.lua @@ -83,6 +83,22 @@ studio.Bank={} studio.CommandReplay={} ---@class FMOD.Studio.ParamDescription +---@field name string +---@field id unknown +---@field minimum number +---@field maximum number +---@field defaultvalue number +---@field type unknown +---@field flags unknown +---@field guid FMOD.GUID + +---@class FMOD.Studio.UserProperty +---@field name string +---@field type 0|1|2|3 int, bool, float, string +---@field intvalue integer +---@field boolvalue 0|1 +---@field floatvalue number +---@field stringvalue string ---@return FMOD.Result function core.System:release() @@ -2704,7 +2720,7 @@ function studio.System:getParameterDescriptionByName(i1) return o1[0],result end ----@return any,FMOD.Result +---@return FMOD.Studio.ParamDescription,FMOD.Result function studio.System:getParameterDescriptionByID(i1) local o1=ffi.new("FMOD_STUDIO_PARAMETER_DESCRIPTION[1]") local result=C2.FMOD_Studio_System_GetParameterDescriptionByID(self,i1,o1) @@ -2924,7 +2940,7 @@ function studio.System:getParameterDescriptionCount() return o1[0],result end ----@return any,number,FMOD.Result +---@return FMOD.Studio.ParamDescription[],number,FMOD.Result function studio.System:getParameterDescriptionList(i1) local o1=ffi.new("FMOD_STUDIO_PARAMETER_DESCRIPTION[?]", i1) local o2=ffi.new("int[1]") @@ -3011,7 +3027,7 @@ function studio.EventDescription:getParameterDescriptionCount() end ---@param i1 number ----@return any,FMOD.Result +---@return FMOD.Studio.ParamDescription,FMOD.Result function studio.EventDescription:getParameterDescriptionByIndex(i1) local o1=ffi.new("FMOD_STUDIO_PARAMETER_DESCRIPTION[1]") local result=C2.FMOD_Studio_EventDescription_GetParameterDescriptionByIndex(self,i1,o1) @@ -3019,14 +3035,14 @@ function studio.EventDescription:getParameterDescriptionByIndex(i1) end ---@param i1 string ----@return any,FMOD.Result +---@return FMOD.Studio.ParamDescription,FMOD.Result function studio.EventDescription:getParameterDescriptionByName(i1) local o1=ffi.new("FMOD_STUDIO_PARAMETER_DESCRIPTION[1]") local result=C2.FMOD_Studio_EventDescription_GetParameterDescriptionByName(self,i1,o1) return o1[0],result end ----@return any,FMOD.Result +---@return FMOD.Studio.ParamDescription,FMOD.Result function studio.EventDescription:getParameterDescriptionByID(i1) local o1=ffi.new("FMOD_STUDIO_PARAMETER_DESCRIPTION[1]") local result=C2.FMOD_Studio_EventDescription_GetParameterDescriptionByID(self,i1,o1) @@ -3068,14 +3084,14 @@ function studio.EventDescription:getUserPropertyCount() end ---@param i1 number ----@return any,FMOD.Result +---@return FMOD.Studio.UserProperty?,FMOD.Result function studio.EventDescription:getUserPropertyByIndex(i1) local o1=ffi.new("FMOD_STUDIO_USER_PROPERTY[1]") local result=C2.FMOD_Studio_EventDescription_GetUserPropertyByIndex(self,i1,o1) return o1[0],result end ----@return any,FMOD.Result +---@return FMOD.Studio.UserProperty?,FMOD.Result function studio.EventDescription:getUserProperty(i1) local o1=ffi.new("FMOD_STUDIO_USER_PROPERTY[1]") local result=C2.FMOD_Studio_EventDescription_GetUserProperty(self,i1,o1) diff --git a/assets/songbook.lua b/assets/songbook.lua index 09f25c2a..9085cf88 100644 --- a/assets/songbook.lua +++ b/assets/songbook.lua @@ -4,7 +4,10 @@ ---@field title string ---@field inside? boolean ---@field redirect? string|table +--- ---@field notFound? boolean +---@field intensity? boolean +---@field section? boolean ---@enum (key) Techmino.MusicName local songbook={ diff --git a/main.lua b/main.lua index dc732f6a..d407822d 100644 --- a/main.lua +++ b/main.lua @@ -622,11 +622,12 @@ if tostring(FMOD.studio):find('NULL') or TABLE.getSize(FMOD.banks)==0 then else FMOD.setMainVolume(SETTINGS.system.mainVol,true) for name,data in next,SONGBOOK do - if FMOD.music.getDesc(name) then - data.intensity=FMOD.music.getParamDesc(name,'intensity')~=nil - data.section=FMOD.music.getParamDesc(name,'section')~=nil - if not FMOD.music.getParamDesc(name,'fade') then - MSG.new('warn',"Missing 'fade' parameter in music '"..name.."'",0) + local ED=FMOD.music.getDesc(name) + if ED then + data.intensity=select(2,ED:getParameterDescriptionByName('intensity'))==FMOD.FMOD_OK + data.section=select(2,ED:getParameterDescriptionByName('section'))==FMOD.FMOD_OK + if select(2,ED:getParameterDescriptionByName('fade'))~=FMOD.FMOD_OK then + MSG.new('warn',"Missing 'fade' parameter in music '"..name.."'") end else data.notFound=true