Skip to content

Commit

Permalink
整理补充fmod相关语法注释
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Jul 1, 2024
1 parent d88a275 commit 0d96b52
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
22 changes: 6 additions & 16 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})

--------------------------

Expand Down
30 changes: 23 additions & 7 deletions assets/fmod20221/wrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]")
Expand Down Expand Up @@ -3011,22 +3027,22 @@ 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)
return o1[0],result
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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions assets/songbook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
---@field title string
---@field inside? boolean
---@field redirect? string|table<string>
---
---@field notFound? boolean
---@field intensity? boolean
---@field section? boolean

---@enum (key) Techmino.MusicName
local songbook={
Expand Down
11 changes: 6 additions & 5 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d96b52

Please sign in to comment.