Yes. This is how AudioStreamer works.May be it's possible to analyse the raw data continously?
Sub AmplitudeCheck_tick
level=A.AudioMaxAmplitude/2700.0
rec.Initialize(20,100,15+level*100,140)
cn.DrawColor(Colors.RGB(0,0,0))
cn.DrawRect(rec,Colors.Red,True,5dip)
Panel1.Invalidate
'Label1.Text=level
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Level")
cn.Initialize(Panel1)
'Calls sub AmplitudeCheck every 500 milliseconds
T.Initialize("AmplitudeCheck",100)
'Set up recorder
A.Initialize
A.AudioSource=A.AS_MIC
...
Sub Activity_Create(FirstTime As Boolean)
'Mute the internal Mic:
Dim R As Reflector
R.Target = R.GetContext
R.Target = R.RunMethod2("getSystemService", "audio", "java.lang.String")
R.RunMethod2("setMicrophoneMute", True, "java.lang.boolean")
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Level")
cn.Initialize(Panel1)
'Calls sub AmplitudeCheck every 500 milliseconds
T.Initialize("AmplitudeCheck",100)
'Set up recorder
A.Initialize
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 AmplitudeCheck_tick
'level=A.AudioMaxAmplitude/2700.0
level=A.AudioMaxAmplitude/44100
rec.Initialize(20,100,15+level*100,140)
cn.DrawColor(Colors.RGB(0,0,0))
cn.DrawRect(rec,Colors.Red,True,5dip)
Panel1.Invalidate
Label1.Text=level
End Sub
'Calls sub AmplitudeCheck every 500 milliseconds
T.Initialize("AmplitudeCheck",100)
Start
Reset High-Flag
Set time counter = impulse counter = 0
Begin Loop
Is Level HIGH?
Yes No
High Flag set?
Yes No
Wait a time Increase impulse counter
Set High Flag
Increase time counter
Time counter = preset interval value?
Yes No
Output value Goto Begin Loop
Goto Start