رفتن به مطلب
  • 0

مشکل در ادرس لود صدا soundpool


mohammade79

سوال

سلام دوستان یه برنامه پیانو میسازم ک روی این دکنه ها کیلیک میکنی یه سری نت و اهنگ اجرا میشه رو هر دکمه ک میخوام وقتی روی دکمه اکورد زدم ادرس صدا ها عوض بشه که نمیشه همش یجور پخش میکنه این سورس کدامه

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

End Sub

Sub Activity_Create(FirstTime As Boolean)

	phonewake.KeepAlive(True)
	
	Activity.LoadLayout("1")
	list_TOUCHING.Initialize
	list_TOUCHED.Initialize
	G.SetOnTouchListener(Activity, "GesturesTouch")
	TouchMap.Initialize
	loadsound
	setallpanels
	mc1.Initialize2("mc1")
	mc2.Initialize2("mc2")
	mc3.Initialize2("mc3")
	mc1.Load(File.DirAssets,"chord1.ogg")
	mc2.Load(File.DirAssets,"chord2.ogg")
	mc3.Load(File.DirAssets,"chord3.ogg")
	ImageView3.Visible=False
	Button16.Visible=False
	Button17.Visible=False
	Button18.Visible=False
	

	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 bm
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"bm/" & i & ".mp3")
	Next
End Sub

Sub g1
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"g/" & i & ".mp3")
	Next
End Sub
Sub a
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"a/" & i & ".mp3")
	Next
End Sub

Sub e
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"e/" & i & ".mp3")
	Next
End Sub

Sub fm
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"fm/" & i & ".mp3")
	Next
End Sub

Sub f
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"f/" & i & ".mp3")
	Next
End Sub

Sub d
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"d/" & i & ".mp3")
	Next
End Sub

Sub c
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"c/" & i & ".mp3")
	Next
End Sub

Sub em
	If piano_mp.IsInitialized = True Then Return
	piano_mp.Initialize(6)
	For i = 0 To pnl_keys.Length-1
		piano_mp.Load(File.DirAssets,"em/" & 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)
		If index =0 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key1)
		End If
		If index =1 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key2)
		End If
		If index =2 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key3)
		End If
		If index =3 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key4)
		End If
		If index =4 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key5)
		End If
		If index =5 Then 
				ic.ScaleFromCenterToTopBottomBack("ic",250)
				ic.StartAnim(key6)
		End If
	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
	
	bt.Initialize(LoadBitmap(File.DirAssets,"am2.png"))
	Button1.Background = bt
		mc1.Play
		mc1.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
	'		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 button2_click
	
	bt.Initialize(LoadBitmap(File.DirAssets,"bm1.png"))
	Button2.Background = bt
	mc2.Play
		mc2.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		bm
End Sub
Sub button3_click
	
	bt.Initialize(LoadBitmap(File.DirAssets,"g2.png"))
	Button3.Background = bt
	mc3.Play
		mc3.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		g1
End Sub
Sub button4_click
	bt.Initialize(LoadBitmap(File.DirAssets,"a1.png"))
	Button4.Background = bt
	mc1.Play
		mc1.Looping=False	
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
	a
End Sub
Sub button5_click
	bt.Initialize(LoadBitmap(File.DirAssets,"e1.png"))
	Button5.Background = bt
	mc2.Play
		mc2.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		e
End Sub
Sub button6_click
	bt.Initialize(LoadBitmap(File.DirAssets,"fm1.png"))
	Button6.Background = bt
	
	mc3.Play
		mc3.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		fm
End Sub
Sub button7_click
	bt.Initialize(LoadBitmap(File.DirAssets,"f1.png"))
	Button7.Background = bt
	mc2.Play
		mc2.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		f
End Sub
Sub button8_click
	bt.Initialize(LoadBitmap(File.DirAssets,"d1.png"))
	Button8.Background = bt
	mc1.Play
		mc1.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		d
End Sub
Sub button9_click
	bt.Initialize(LoadBitmap(File.DirAssets,"c1.png"))
	Button9.Background = bt
	mc3.Play
		mc3.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"em.png"))
		Button10.Background = bt
		c
End Sub
Sub button10_click
bt.Initialize(LoadBitmap(File.DirAssets,"em1.png"))
	Button10.Background = bt
	mc2.Play
		mc2.Looping=False
		bt.Initialize(LoadBitmap(File.DirAssets,"am1.png"))
		Button1.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"bm.png"))
		Button2.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"g1.png"))
		Button3.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"a.png"))
		Button4.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"e.png"))
		Button5.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"fm.png"))
		Button6.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"f.png"))
		Button7.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"d.png"))
		Button8.Background = bt
		bt.Initialize(LoadBitmap(File.DirAssets,"c.png"))
		Button9.Background = bt
		em
End Sub
Sub button11_click
	StartActivity(selectr)
	slide.SetAnimation("file3","file4")
End Sub
Sub button12_click
	StartActivity(chords)
	slide.SetAnimation("file3","file4")
End Sub
Sub button13_click
	StartActivity(help)
	slide.SetAnimation("file3","file4")
End Sub
Sub button14_click
	fad.FadeIn("fad",500)
	fad.StartAnim(ImageView3)
	ImageView3.Visible=True
	Button16.Visible=True
	Button17.Visible=True
	Button18.Visible=True
End Sub
Sub button16_click
	fad.FadeOut("fad",500)
	fad.StartAnim(ImageView3)
	Activity.SetBackgroundImage(LoadBitmap(File.DirAssets,"main1.jpg"))
	Button16.Visible=False
	Button17.Visible=False
	Button18.Visible=False
	ImageView3.Visible=False
End Sub
Sub button17_click
	fad.FadeOut("fad",500)
	fad.StartAnim(ImageView3)
	Activity.SetBackgroundImage(LoadBitmap(File.DirAssets,"main2.jpg"))
	Button16.Visible=False
	Button17.Visible=False
	Button18.Visible=False
	ImageView3.Visible=False
End Sub
Sub button18_click
	fad.FadeOut("fad",500)
	fad.StartAnim(ImageView3)
	Button16.Visible=False
	Button17.Visible=False
	Button18.Visible=False
	ImageView3.Visible=False
End Sub

 

لینک ارسال
به اشتراک گذاری در سایت های دیگر

0 پاسخ به این سوال تاکنون داده شده است

ارسال‌های توصیه شده

هنوز برای این سوال پاسخی ارسال نشده است

بایگانی شده

این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.

  • کاربران آنلاین در این صفحه   0 کاربر

    • هیچ کاربر عضوی،در حال مشاهده این صفحه نیست.
×
×
  • اضافه کردن...