سلام عزیزان یه کد تار نوشتم که دقیقا کار میکنه به بهترین نحو ممکن با soundpool ولی با زدن دکمه های دیگر میخوام ادرس اهنگ ها رو عوض کنم که متاسفانه لود نمیکنه لطفا کمکم کنید .اقعا گیز کردم خیلی تو این انجمن کار راه انداختم لطفا یکی کمک کنه اگر بلده
#Region Project Attributes
#ApplicationLabel: Guitar Irani Pro +
#VersionCode: 1
#VersionName: 1.0
#SupportedOrientations: landscape
#CanInstallToExternalStorage: true
#AdditionalRes: ..\res
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: False
#End Region
Sub Process_Globals
Dim piano_mp As SoundPool
End Sub
Sub Globals
Type Point(Id As Int, prevX As Int, prevY As Int)
Private list_TOUCHING, list_TOUCHED As List
Dim G As Gestures
Dim TouchMap As Map
Dim pnl_keys(6) As Panel
Private key1,key2,key3,key4,key5,key6 As Panel
Dim ic As ICOSScaleAnimation
Private Button1,Button2,Button3,Button4,Button5,Button6,Button7,Button8,Button9,Button10,Button11,button12 As Button
Dim s As String
Dim bt As BitmapDrawable
Dim mc1,mc2,mc3 As MediaPlayer
Private ImageView3 As ImageView
Private Button16 As Button
Private Button17 As Button
Private Button18 As Button
Dim sd As SDialog
Dim baz As BazaarInstallerChecker
Dim fad As ICOSFadeAnimation
Dim str As String
Dim phonewake As PhoneWakeState
Dim sdlabel As Label
Dim MyFade As splashfade
Dim ShowSplashScreen As Boolean : ShowSplashScreen = True
Dim MyPan As Panel
Dim MyB As Button
MyB.Initialize("MyB")
MyPan.Initialize("MyPan")
End Sub
Sub Activity_Create(FirstTime As Boolean)
phonewake.KeepAlive(True)
Activity.LoadLayout("1")
If FirstTime Then
If ShowSplashScreen = True Then
Activity.AddView(MyPan, 0, 0, Activity.Width, Activity.Height) :
End If
If ShowSplashScreen = True Then
If FirstTime Then
MyFade.Initialize(Activity,Me,"splash1.jpg",Gravity.FILL,3000,100,"Left")
MyPan.Visible = False
End If
End If
End If
DoEvents
list_TOUCHING.Initialize
list_TOUCHED.Initialize
G.SetOnTouchListener(Activity, "GesturesTouch")
TouchMap.Initialize
loadsound
setallpanels
End Sub
Sub loadsound
If piano_mp.IsInitialized = True Then Return
piano_mp.Initialize(6)
For i = 0 To pnl_keys.Length-1
piano_mp.Load(File.DirAssets, "newsound/" & i & ".mp3")
Next
End Sub
Sub am
If piano_mp.IsInitialized = True Then Return
piano_mp.Initialize(6)
For i = 0 To pnl_keys.Length-1
piano_mp.Load(File.DirAssets,"am/" & i & ".mp3")
Next
End Sub
Sub setallpanels
pnl_keys(0) = key1
pnl_keys(1) = key2
pnl_keys(2) = key3
pnl_keys(3) = key4
pnl_keys(4) = key5
pnl_keys(5) = key6
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
setallkeystofalse
End Sub
Sub setallkeystofalse
list_TOUCHING.Clear
list_TOUCHING.Clear
TouchMap.Clear
resetcolors
End Sub
Sub resetcolors
End Sub
Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
Dim p As Point
Select Action
Case G.ACTION_DOWN, G.ACTION_POINTER_DOWN
p.Id = PointerID
TouchMap.Put(PointerID, p)
Case G.ACTION_POINTER_UP
TouchMap.Remove(PointerID)
Case G.ACTION_UP
setallkeystofalse
End Select
list_TOUCHING.Clear 'reset touching list
For i = 0 To TouchMap.Size - 1
Dim px, py As Int
p = TouchMap.GetValueAt(i)
px = G.GetX(p.id)
py = G.GetY(p.id)
For Each pnl As Panel In pnl_keys
If px > pnl.Left And px < pnl.Left + pnl.Width Then
If py > pnl.Top And py < pnl.Top + pnl.Height Then
If pnl.Tag > 4 Then
If list_TOUCHED.IndexOf("0") > -1 Or list_TOUCHED.IndexOf("1") > -1 Or list_TOUCHED.IndexOf("2") > -1 Or list_TOUCHED.IndexOf("3") > -1 Or list_TOUCHED.IndexOf("4") > -1 Then
If py < pnl_keys(0).Height Then
If pnl.Tag = "5" Or pnl.Tag = "6" Then 'right side
If px > (pnl.Left + pnl.Width) - (pnl_keys(0).Width / 2) Then Continue
else if pnl.Tag = "6" Or pnl.Tag = "11" Then 'left side
If px < pnl.Left + (pnl_keys(0).Width / 2) Then Continue
else if pnl.tag = "6" Then
'do nithing - full white key
Else
If px > (pnl.Left + pnl.Width) - (pnl_keys(0).Width / 2) Or px < pnl.Left + (pnl_keys(0).Width / 2) Then Continue
End If
End If
End If
End If
list_TOUCHING.Add(pnl.Tag)
If list_TOUCHED.IndexOf(pnl.Tag) = -1 Then
list_TOUCHED.Add(pnl.Tag)
piano_mp.Play(pnl.Tag+1,1,1,1,0,1)
End If
End If
End If
Next
Next
resetcolors
For i = 0 To list_TOUCHING.Size - 1
Dim index As String = list_TOUCHING.Get(i)
Next
For i = (list_TOUCHED.Size-1) To 0 Step -1
If list_TOUCHING.IndexOf(list_TOUCHED.Get(i)) = -1 Then list_TOUCHED.RemoveAt(i)
Next
Return True
End Sub
Sub button1_click
am
End Sub
هر چی رو کلید ای ام میزنم بازم همون صدایی که اول ساختم رو لود میکنه فایل رو تغییر نمیده نمیدونم مشل چیع
سوال
mohammade79 127
سلام عزیزان یه کد تار نوشتم که دقیقا کار میکنه به بهترین نحو ممکن با soundpool ولی با زدن دکمه های دیگر میخوام ادرس اهنگ ها رو عوض کنم که متاسفانه لود نمیکنه لطفا کمکم کنید .اقعا گیز کردم خیلی تو این انجمن کار راه انداختم لطفا یکی کمک کنه اگر بلده
#Region Project Attributes #ApplicationLabel: Guitar Irani Pro + #VersionCode: 1 #VersionName: 1.0 #SupportedOrientations: landscape #CanInstallToExternalStorage: true #AdditionalRes: ..\res #End Region #Region Activity Attributes #FullScreen: true #IncludeTitle: False #End Region Sub Process_Globals Dim piano_mp As SoundPool End Sub Sub Globals Type Point(Id As Int, prevX As Int, prevY As Int) Private list_TOUCHING, list_TOUCHED As List Dim G As Gestures Dim TouchMap As Map Dim pnl_keys(6) As Panel Private key1,key2,key3,key4,key5,key6 As Panel Dim ic As ICOSScaleAnimation Private Button1,Button2,Button3,Button4,Button5,Button6,Button7,Button8,Button9,Button10,Button11,button12 As Button Dim s As String Dim bt As BitmapDrawable Dim mc1,mc2,mc3 As MediaPlayer Private ImageView3 As ImageView Private Button16 As Button Private Button17 As Button Private Button18 As Button Dim sd As SDialog Dim baz As BazaarInstallerChecker Dim fad As ICOSFadeAnimation Dim str As String Dim phonewake As PhoneWakeState Dim sdlabel As Label Dim MyFade As splashfade Dim ShowSplashScreen As Boolean : ShowSplashScreen = True Dim MyPan As Panel Dim MyB As Button MyB.Initialize("MyB") MyPan.Initialize("MyPan") End Sub Sub Activity_Create(FirstTime As Boolean) phonewake.KeepAlive(True) Activity.LoadLayout("1") If FirstTime Then If ShowSplashScreen = True Then Activity.AddView(MyPan, 0, 0, Activity.Width, Activity.Height) : End If If ShowSplashScreen = True Then If FirstTime Then MyFade.Initialize(Activity,Me,"splash1.jpg",Gravity.FILL,3000,100,"Left") MyPan.Visible = False End If End If End If DoEvents list_TOUCHING.Initialize list_TOUCHED.Initialize G.SetOnTouchListener(Activity, "GesturesTouch") TouchMap.Initialize loadsound setallpanels End Sub Sub loadsound If piano_mp.IsInitialized = True Then Return piano_mp.Initialize(6) For i = 0 To pnl_keys.Length-1 piano_mp.Load(File.DirAssets, "newsound/" & i & ".mp3") Next End Sub Sub am If piano_mp.IsInitialized = True Then Return piano_mp.Initialize(6) For i = 0 To pnl_keys.Length-1 piano_mp.Load(File.DirAssets,"am/" & i & ".mp3") Next End Sub Sub setallpanels pnl_keys(0) = key1 pnl_keys(1) = key2 pnl_keys(2) = key3 pnl_keys(3) = key4 pnl_keys(4) = key5 pnl_keys(5) = key6 End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) setallkeystofalse End Sub Sub setallkeystofalse list_TOUCHING.Clear list_TOUCHING.Clear TouchMap.Clear resetcolors End Sub Sub resetcolors End Sub Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean Dim p As Point Select Action Case G.ACTION_DOWN, G.ACTION_POINTER_DOWN p.Id = PointerID TouchMap.Put(PointerID, p) Case G.ACTION_POINTER_UP TouchMap.Remove(PointerID) Case G.ACTION_UP setallkeystofalse End Select list_TOUCHING.Clear 'reset touching list For i = 0 To TouchMap.Size - 1 Dim px, py As Int p = TouchMap.GetValueAt(i) px = G.GetX(p.id) py = G.GetY(p.id) For Each pnl As Panel In pnl_keys If px > pnl.Left And px < pnl.Left + pnl.Width Then If py > pnl.Top And py < pnl.Top + pnl.Height Then If pnl.Tag > 4 Then If list_TOUCHED.IndexOf("0") > -1 Or list_TOUCHED.IndexOf("1") > -1 Or list_TOUCHED.IndexOf("2") > -1 Or list_TOUCHED.IndexOf("3") > -1 Or list_TOUCHED.IndexOf("4") > -1 Then If py < pnl_keys(0).Height Then If pnl.Tag = "5" Or pnl.Tag = "6" Then 'right side If px > (pnl.Left + pnl.Width) - (pnl_keys(0).Width / 2) Then Continue else if pnl.Tag = "6" Or pnl.Tag = "11" Then 'left side If px < pnl.Left + (pnl_keys(0).Width / 2) Then Continue else if pnl.tag = "6" Then 'do nithing - full white key Else If px > (pnl.Left + pnl.Width) - (pnl_keys(0).Width / 2) Or px < pnl.Left + (pnl_keys(0).Width / 2) Then Continue End If End If End If End If list_TOUCHING.Add(pnl.Tag) If list_TOUCHED.IndexOf(pnl.Tag) = -1 Then list_TOUCHED.Add(pnl.Tag) piano_mp.Play(pnl.Tag+1,1,1,1,0,1) End If End If End If Next Next resetcolors For i = 0 To list_TOUCHING.Size - 1 Dim index As String = list_TOUCHING.Get(i) Next For i = (list_TOUCHED.Size-1) To 0 Step -1 If list_TOUCHING.IndexOf(list_TOUCHED.Get(i)) = -1 Then list_TOUCHED.RemoveAt(i) Next Return True End Sub Sub button1_click am End Sub
هر چی رو کلید ای ام میزنم بازم همون صدایی که اول ساختم رو لود میکنه فایل رو تغییر نمیده نمیدونم مشل چیع
لینک ارسال
به اشتراک گذاری در سایت های دیگر
1 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.