三个音频模块升级不再依赖全局变量SETTING
但更新音量的时候必须需手动调用setVol 整理代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local VOC={
|
||||
vol=1,
|
||||
getCount=function()return 0 end,
|
||||
getQueueCount=function()return 0 end,
|
||||
load=function()error("Cannot load before init!")end,
|
||||
@@ -6,6 +7,10 @@ local VOC={
|
||||
play=NULL,
|
||||
update=NULL,
|
||||
}
|
||||
function VOC.setVol(v)
|
||||
assert(type(v)=='number'and v>=0 and v<=1)
|
||||
VOC.vol=v
|
||||
end
|
||||
function VOC.init(list)
|
||||
VOC.init=nil
|
||||
local rnd=math.random
|
||||
@@ -67,7 +72,7 @@ function VOC.init(list)
|
||||
end
|
||||
|
||||
function VOC.play(s,chn)
|
||||
if SETTING.voc>0 then
|
||||
if VOC.vol>0 then
|
||||
local _=Source[s]
|
||||
if not _ then return end
|
||||
if chn then
|
||||
@@ -90,13 +95,13 @@ function VOC.init(list)
|
||||
end
|
||||
elseif Q.s==1 then--Waiting load source
|
||||
Q[1]=_getVoice(Q[1])
|
||||
Q[1]:setVolume(SETTING.voc)
|
||||
Q[1]:setVolume(VOC.vol)
|
||||
Q[1]:play()
|
||||
Q.s=Q[2]and 2 or 4
|
||||
elseif Q.s==2 then--Playing 1,ready 2
|
||||
if Q[1]:getDuration()-Q[1]:tell()<.08 then
|
||||
Q[2]=_getVoice(Q[2])
|
||||
Q[2]:setVolume(SETTING.voc)
|
||||
Q[2]:setVolume(VOC.vol)
|
||||
Q[2]:play()
|
||||
Q.s=3
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user