diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index d0acecac..c148aaa9 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -1,5 +1,7 @@ +local Sources={} +local volume=1 + local BGM={ - vol=1, default=false, getList=function()error("Cannot getList before initialize!")end, getCount=function()return 0 end, @@ -13,7 +15,7 @@ local BGM={ local function task_fadeOut(src) while true do coroutine.yield() - local v=src:getVolume()-.025*BGM.vol + local v=src:getVolume()-.025*volume src:setVolume(v>0 and v or 0) if v<=0 then src:pause() @@ -24,10 +26,10 @@ end local function task_fadeIn(src) while true do coroutine.yield() - local v=BGM.vol + local v=volume v=math.min(v,src:getVolume()+.025*v) src:setVolume(v) - if v>=BGM.vol then + if v>=volume then return true end end @@ -43,11 +45,10 @@ function BGM.setChange(func) end function BGM.setVol(v) assert(type(v)=='number'and v>=0 and v<=1) - BGM.vol=v + volume=v end function BGM.init(list) BGM.init=nil - local Sources={} local simpList={} for _,v in next,list do @@ -57,6 +58,7 @@ function BGM.init(list) table.sort(simpList) function BGM.getList()return simpList end local count=#simpList + LOG(count.." BGM files loaded") function BGM.getCount()return count end local function _load(name) @@ -77,10 +79,10 @@ function BGM.init(list) end function BGM.setVol(v) assert(type(v)=='number'and v>=0 and v<=1) - BGM.vol=v + volume=v if BGM.playing then - if BGM.vol>0 then - BGM.playing:setVolume(BGM.vol) + if volume>0 then + BGM.playing:setVolume(volume) BGM.playing:play() elseif BGM.nowPlay then BGM.playing:pause() @@ -95,7 +97,7 @@ function BGM.init(list) function BGM.play(name) name=name or BGM.default if not _load(name)then return end - if BGM.vol==0 then + if volume==0 then BGM.nowPlay=name BGM.playing=Sources[name] return true diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index f2dd64e6..acbc759e 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -40,14 +40,17 @@ function SFX.init(list) for i=1,#list do ins(sfxList,list[i])end end function SFX.load(path) + local c=0 for i=1,#sfxList do local fullPath=path..sfxList[i]..'.ogg' if love.filesystem.getInfo(fullPath)then Sources[sfxList[i]]={love.audio.newSource(fullPath,'static')} + c=c+1 else LOG("No SFX: "..sfxList[i]..'.ogg',.1) end end + LOG(c.."/"..#sfxList.." SFX files loaded") end function SFX.loadSample(pack) assert(type(pack)=='table',"Usage: SFX.loadsample([table])") @@ -61,7 +64,7 @@ function SFX.loadSample(pack) Sources[pack.name..num]={love.audio.newSource(pack.path..'/'..num..'.ogg','static')} num=num+1 end - LOG("Pack "..pack.name.." loaded, "..(num-1).." files") + LOG((num-1).." "..pack.name.." samples loaded") end function SFX.getCount() diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index cabb37e5..3ef6400e 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -23,10 +23,9 @@ local loadingThread=coroutine.wrap(function() end YIELD() YIELD('loadSFX')SFX.load('media/effect/'..SETTING.sfxPack..'/') - YIELD('loadSample') - SFX.loadSample{name='bass',path='media/sample/bass',base='A2'} - SFX.loadSample{name='lead',path='media/sample/lead',base='A3'} - SFX.loadSample{name='bell',path='media/sample/bell',base='A4'} + YIELD('loadSample')SFX.loadSample{name='bass',path='media/sample/bass',base='A2'} + YIELD('loadSample')SFX.loadSample{name='lead',path='media/sample/lead',base='A3'} + YIELD('loadSample')SFX.loadSample{name='bell',path='media/sample/bell',base='A4'} YIELD('loadVoice')VOC.load('media/vocal/'..SETTING.vocPack..'/') YIELD('loadFont')for i=1,17 do getFont(15+5*i)end