Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim T As Timer
Dim A As AudioRecorder
Dim timer1 As Timer
Dim SP As SoundPool
Dim LoadId1, PlayId1, LoadId2, PlayId2 As Int
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 Panel1 As Panel
Dim speak1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
SP.Initialize(1)
LoadId1 = SP.Load(File.DirAssets, "Pushy.mp3")
LoadId2 = SP.Load(File.DirAssets, "long_fart.ogg")
End If
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("main.bal")
timer1.Initialize("timer1", 3000)
timer1.Enabled = True
'Calls sub AmplitudeCheck every 500 milliseconds
T.Initialize("AmplitudeCheck",500)
'Set up recorder
A.AudioSource=A.AS_MIC
A.OutputFormat=A.OF_THREE_GPP
A.AudioEncoder=A.AE_AMR_NB
A.setOutputFile("","/dev/null")
A.prepare
A.start
T.Enabled=True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
T.Enabled=False
A.stop
End Sub
Sub timer1_Tick
speak1.Visible = False
End Sub
Sub AmplitudeCheck_tick
Level=A.AudioMaxAmplitude
'PlayId1 = SP.Play(LoadId1, 1, 1, 1, 2, 1) 'Uncommenting this only has the sound file play all the time over and over
'Log(Level)
End Sub