'********************************
'********************************
'Work only at API13 - Android 3.2
'Autor: Jenki
'Used Lib: UltimateAudio
'********************************
'********************************
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim UAV As UAVisualization
Dim Timer1 As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim cn As Canvas
Dim rec As Rect
Dim level As Int
Dim Panel1 As Panel
Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main.bal")
Timer1.Initialize("Timer1",100)
cn.Initialize(Panel1) 'Initializ the Panel in Canvas
UAV.initialize("UAVV",0) 'Initialize the Visualizer. 0 is for the Generalsoung
UAV.setCaptureSize(512) 'Set the Max Buffer
UAV.setEnabled(True) 'Set Enable
End Sub
Sub Activity_Resume
If UAV.Enabled=False Then
UAV.setEnabled(True)
End If
Timer1.Enabled=False
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Timer1.Enabled=False
UAV.setEnabled(False)
End Sub
Sub Timer1_Tick
Dim MBytes(511) As Byte 'Byte in 512 Array = Max BufferSize
uav.getWaveForm(MBytes) 'Get the Byte from getWaveForm
cn.DrawColor(Colors.RGB(0,0,0)) 'Clear Pannel
For i = 0 To MBytes.Length -1
level=Bit.And(MBytes(i), 0xff) 'Convert unsignat Byte
Log(level)
rec.Initialize(0+i,level,1+i,300) 'Set line
cn.DrawRect(rec,Colors.Red,True,5dip) 'Draw Line
Next
Panel1.Invalidate 'Refresh Panel
End Sub
Sub Panel1_Click
End Sub
Sub Button1_Click
If Timer1.Enabled=True Then
Timer1.Enabled=False
Button1.Text="Timer = off"
Else
Timer1.Enabled=True
Button1.Text="Timer = on"
End If
End Sub