Hi all.
this example play Happy birthday to you music with beep. (Audio librarie)
THX
this example play Happy birthday to you music with beep. (Audio librarie)
B4X:
Sub Globals
Private lNotas As List
Private lbNotas As Label
Private tocando As Boolean
End Sub
Sub Activity_Create(FirstTime As Boolean)
If Not(lNotas.IsInitialized) Then lNotas.Initialize
Activity.LoadLayout("1")
'PRIMEIRA PARTE
lNotas.Add(Array(300,528,"PA"))
lNotas.Add(Array(300,528,"RA"))
lNotas.Add(Array(500,594,"BENS"))
lNotas.Add(Array(500,528,"PRA"))
lNotas.Add(Array(400,704,"VO"))
lNotas.Add(Array(1400,660,"CE"))
'SEGUNDA PARTE
lNotas.Add(Array(200,528,"NES"))
lNotas.Add(Array(200,528,"TA"))
lNotas.Add(Array(600,594,"DATA"))
lNotas.Add(Array(600,528,"QUE"))
lNotas.Add(Array(400,792,"RI"))
lNotas.Add(Array(1400,704,"DA"))
'TERCEIRA PARTE
lNotas.Add(Array(200,880,"MUI"))
lNotas.Add(Array(200,880,"TAS"))
lNotas.Add(Array(600,1056,"FE"))
lNotas.Add(Array(400,880,"LI"))
lNotas.Add(Array(400,704,"CI"))
lNotas.Add(Array(400,660,"DA"))
lNotas.Add(Array(1300,594,"DES"))
'QUARTA PARTE
lNotas.Add(Array(200,933,"MUITOS"))
lNotas.Add(Array(200,933,"A"))
lNotas.Add(Array(600,880,"NOS"))
lNotas.Add(Array(600,704,"DE"))
lNotas.Add(Array(600,792,"VI"))
lNotas.Add(Array(1600,704,"DA"))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Toca_beeper
tocando = True
For i = 0 To lNotas.Size - 1
Dim value() As Object = lNotas.Get(i)
lbNotas.Text = value(2)
Dim b As Beeper
b.Initialize(value(0), value(1))
b.Beep
Sleep(value(0))
b.Release
Next
tocando = False
lbNotas.Text = ""
End Sub
Sub btTocar_Click
If Not(tocando) Then
Toca_beeper
End If
End Sub
THX
Attachments
Last edited: