Hi,
Am trying to have the android microphone detect sound input and play a sound file when it gets so loud.
I have followed the audio recorder threads and have used the example that logs the AudioMaxAmplitube, not what i want to do is when the level reaches 5000 or what ever a sound file is played.
Is this going to be possible as i need it to be as close to real time as possible so recording to a file then playing a sound if the AudioMaxAmplitude reaches 5000, i think is going to be to slow.
Any help would be great.
Am trying to have the android microphone detect sound input and play a sound file when it gets so loud.
I have followed the audio recorder threads and have used the example that logs the AudioMaxAmplitube, not what i want to do is when the level reaches 5000 or what ever a sound file is played.
Is this going to be possible as i need it to be as close to real time as possible so recording to a file then playing a sound if the AudioMaxAmplitude reaches 5000, i think is going to be to slow.
Any help would be great.
B4X:
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
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)
'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
Log(Level)
End Sub