Skip to content

Commit a5b9e03

Browse files
committed
优化四部和声app
添加主菜单快捷键
1 parent 645cb7e commit a5b9e03

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

assets/scene/main_out.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ local function sysAction(action)
2727
end
2828
function scene.keyDown(key,isRep)
2929
if key=='z' then SCN.go('piano') return true
30+
elseif key=='x' then SCN.go('harmony4') return true
3031
elseif key=='b' then playExterior('brik/exterior/test')() return true
3132
elseif key=='g' then playExterior('gela/test')() return true
3233
elseif key=='a' then playExterior('acry/test')() return true

assets/scene_app/harmony4.lua

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ function Voice.init(v)
2323
if not v.vol then v.vol=.626 end
2424
v.sounds={}
2525
for i=1,3 do
26-
v.sounds[i]=FMOD.effect.play(v.wave,{pitch=(262*step^v.tune)/baseFreq})
27-
-- v.sounds[i]:stop()
26+
v.sounds[i]=FMOD.effect.play(v.wave,{pitch=(262*step^v.tune)/baseFreq,param={'release',1000}})
2827
end
2928
return v
3029
end
@@ -45,38 +44,44 @@ function Voice:randomize()
4544
s:setPitch((262*step^(self.tune+MATH.rand(diffMin,diffMax)))/baseFreq)
4645
end
4746
end
47+
function Voice:stop()
48+
for _,v in next,self.sounds do
49+
v:stop(FMOD.FMOD_STUDIO_STOP_ALLOWFADEOUT)
50+
end
51+
end
4852

4953
---@type Techmino.App.Harmony.Voice[]
50-
local voice={
54+
local voiceData={
5155
{
52-
wave='square_wave',
56+
wave='organ_wave',
5357
tune=0,
5458
key='1',
5559
x=-600,
5660
y=0,
5761
},
5862
{
59-
wave='square_wave',
63+
wave='organ_wave',
6064
tune=4,
6165
key='2',
6266
x=-200,
6367
y=0,
6468
},
6569
{
66-
wave='square_wave',
70+
wave='organ_wave',
6771
tune=7,
6872
key='3',
6973
x=200,
7074
y=0,
7175
},
7276
{
73-
wave='square_wave',
77+
wave='organ_wave',
7478
tune=11,
7579
key='4',
7680
x=600,
7781
y=0,
7882
},
7983
}
84+
local voice
8085

8186

8287
---@type Zenitha.Scene
@@ -93,11 +98,19 @@ end
9398

9499
function scene.load()
95100
love.mouse.setRelativeMode(true)
96-
for k,v in next,voice do
101+
voice={}
102+
for k,v in next,voiceData do
97103
voice[k]=Voice.init(v)
98104
voice[k]:volumeChange(0)
99105
end
100106
end
107+
function scene.unload()
108+
love.mouse.setRelativeMode(false)
109+
for _,v in next,voice do
110+
v:stop()
111+
end
112+
voice=nil
113+
end
101114

102115
function scene.mouseDown(x,y,k)
103116
end

0 commit comments

Comments
 (0)