From e8f19d7b5bd18cbd346e088fb1ac15b1194be09e Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Fri, 22 Nov 2024 00:24:11 +0800 Subject: [PATCH] =?UTF-8?q?piano=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E9=85=8D=E8=89=B2=E6=96=B9=E6=A1=88=E8=B0=83=E6=95=B4?= =?UTF-8?q?=20=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scene_app/piano.lua | 54 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/assets/scene_app/piano.lua b/assets/scene_app/piano.lua index d7fd3cb3..151adfa1 100644 --- a/assets/scene_app/piano.lua +++ b/assets/scene_app/piano.lua @@ -1,11 +1,11 @@ +local ins,rem=table.insert,table.remove +local clamp=MATH.clamp local gc=love.graphics local gc_setColor=GC.setColor local gc_rect=GC.rectangle local gc_mStr=GC.mStr local setFont=FONT.set -local ins,rem=table.insert,table.remove - local activeEventMap={} ---@type table local objPool={} ---@type Techmino.Piano.Object[] local inst,offset,release @@ -85,7 +85,7 @@ end ---@field _onRelease? function ---@type Techmino.Piano.Layout[] -local layoutList={ +local layoutData={ {name="Classic-C", pos_x=-70, pos_y=-25, @@ -94,13 +94,15 @@ local layoutList={ templates={ {w=8,h=8,fillC='DS',actvC='dS',lineC='LD',textC='dL'}, -- Treble (black) {w=8,h=8,fillC='LS',actvC='S',lineC='LD',textC='D'}, -- Treble (white) - {w=8,h=8,fillC='DR',actvC='dR',lineC='LD',textC='dL'}, -- Bass (black) - {w=8,h=8,fillC='LR',actvC='R',lineC='LD',textC='D'}, -- Bass (white) + {w=8,h=8,fillC='DF',actvC='dF',lineC='LD',textC='dL'}, -- Bass (black) + {w=8,h=8,fillC='LF',actvC='F',lineC='LD',textC='D'}, -- Bass (white) + {w=8,h=8,fillC='DM',actvC='dM',lineC='LD',textC='dL'}, -- Cross (black) + {w=8,h=8,fillC='LM',actvC='M',lineC='LD',textC='D'}, -- Cross (white) }, keyLayout={ {x=0,y=0,w=140,h=50,fillC={1,1,1,.26},lineC='dL'}, -- Frame - {1,x=010,y=05,key='2'}, -- Line 1 - {1,x=020,y=05,key='3'}, + {5,x=010,y=05,key='2'}, -- Line 1 + {5,x=020,y=05,key='3'}, {1,x=040,y=05,key='5'}, {1,x=050,y=05,key='6'}, {1,x=060,y=05,key='7'}, @@ -108,9 +110,9 @@ local layoutList={ {1,x=090,y=05,key='0'}, {1,x=110,y=05,key='='}, {1,x=120,y=05,w=13,key='backspace'}, - {2,x=005,y=15,key='q'}, -- Line 2 - {2,x=015,y=15,key='w'}, - {2,x=025,y=15,key='e'}, + {6,x=005,y=15,key='q'}, -- Line 2 + {6,x=015,y=15,key='w'}, + {6,x=025,y=15,key='e'}, {2,x=035,y=15,key='r'}, {2,x=045,y=15,key='t'}, {2,x=055,y=15,key='y'}, @@ -126,8 +128,8 @@ local layoutList={ {3,x=050,y=25,key='g'}, {3,x=060,y=25,key='h'}, {3,x=070,y=25,key='j'}, - {3,x=090,y=25,key='l'}, - {3,x=100,y=25,key=';'}, + {5,x=090,y=25,key='l'}, + {5,x=100,y=25,key=';'}, {4,x=015,y=35,key='z'}, -- Line 4 {4,x=025,y=35,key='x'}, {4,x=035,y=35,key='c'}, @@ -135,9 +137,9 @@ local layoutList={ {4,x=055,y=35,key='b'}, {4,x=065,y=35,key='n'}, {4,x=075,y=35,key='m'}, - {4,x=085,y=35,key=','}, - {4,x=095,y=35,key='.'}, - {4,x=105,y=35,key='/'}, + {6,x=085,y=35,key=','}, + {6,x=095,y=35,key='.'}, + {6,x=105,y=35,key='/'}, }, keyMap={ ['2']=37,['3']=39, ['5']=42,['6']=44,['7']=46, ['9']=49,['0']=51, ['=']=54,['backspace']=56, @@ -380,7 +382,7 @@ local function checkColor(input) assert(type(input)=='table',"input should be an exist 'color string' or {R,G,B}, but got "..tostring(input)) return input end -for _,layout in next,layoutList do +for _,layout in next,layoutData do for _,key in ipairs(layout.keyLayout) do if key[1] and layout.templates[key[1]] then TABLE.updateMissing(key,layout.templates[key[1]]) @@ -406,7 +408,7 @@ for _,layout in next,layoutList do key._onRelease=key._onRelease or NULL end end -local layout=layoutList[1] +local layout=layoutData[1] ---@type Zenitha.Scene local scene={} @@ -444,28 +446,28 @@ function scene.keyDown(key,isRep,keyCode) if isKeyDown('lctrl') then note=note-1 end _param.tune=note-26 _param.volume=1 - _param.param[2]=release*1.0594630943592953^(note-26) + _param.param[2]=release*1.0594630943592953^(_param.tune) activeEventMap[keyCode]=FMOD.effect(inst,_param) elseif key=='f3' then - release=MATH.clamp(release-50,0,2600) + release=clamp(release-50,0,2600) elseif key=='f4' then - release=MATH.clamp(release+50,0,2600) + release=clamp(release+50,0,2600) elseif key=='f5' then - presets.rollNote.setSpeed(MATH.clamp(presets.rollNote.getSpeed()/1.2,100,1000)) + presets.rollNote.setSpeed(clamp(presets.rollNote.getSpeed()/1.2,100,1000)) elseif key=='f6' then - presets.rollNote.setSpeed(MATH.clamp(presets.rollNote.getSpeed()*1.2,100,1000)) + presets.rollNote.setSpeed(clamp(presets.rollNote.getSpeed()*1.2,100,1000)) elseif not isRep then if key=='tab' then stopAllSounds() inst=TABLE.next(instList,inst) or instList[1] elseif key=='rshift' then - offset=MATH.clamp(offset+(isKeyDown('ralt') and 12 or isKeyDown('rctrl') and 0.5 or 1),-12,24) + offset=clamp(offset+(isKeyDown('ralt') and 12 or isKeyDown('rctrl') and 0.5 or 1),-12,24) elseif key=='rctrl' then - offset=MATH.clamp(offset-(isKeyDown('ralt') and 12 or isKeyDown('rshift') and 0.5 or 1),-12,24) + offset=clamp(offset-(isKeyDown('ralt') and 12 or isKeyDown('rshift') and 0.5 or 1),-12,24) elseif key=='f1' then - layout=layoutList[(TABLE.find(layoutList,layout)-2)%#layoutList+1] + layout=layoutData[(TABLE.find(layoutData,layout)-2)%#layoutData+1] elseif key=='f2' then - layout=layoutList[TABLE.find(layoutList,layout)%#layoutList+1] + layout=layoutData[TABLE.find(layoutData,layout)%#layoutData+1] elseif key=='escape' then if sureCheck('back') then SCN.back() end end