Sub Process_Globals
Private Microphone As AudioStreamer
Private JNoiseSuppressor As JavaObject
End Sub
Sub MicInit
Microphone.Initialize2(7, "Microphone", 8000, True, 16, Microphone.VOLUME_VOICE_CALL)
Dim r As Reflector
r.Target = Microphone
Dim newBuffer(320) As Byte
r.SetField2("recordBuffer", newBuffer)
'Noise suppressor
Dim arj As JavaObject = r.GetField("audioRecord")
Dim id As Int = arj.RunMethod("getAudioSessionId", Null)
LogColor("Mic audio session ID " & id, Colors.Red)
If JNoiseSuppressor.IsInitialized Then JNoiseSuppressor.RunMethod("release", Null)
JNoiseSuppressor.InitializeStatic("android.media.audiofx.NoiseSuppressor")
JNoiseSuppressor = JNoiseSuppressor.RunMethod("create", Array(arj.RunMethod("getAudioSessionId", Null)))
Dim isAvail As Boolean = JNoiseSuppressor.RunMethod("isAvailable", Null)
LogColor("Noise suppressor available: " & isAvail, Colors.Red)
JNoiseSuppressor.RunMethod("setEnabled", Array(True))
Dim isEnabled As Boolean = JNoiseSuppressor.RunMethod("getEnabled", Null)
LogColor("Noise suppressor enabled: " & isEnabled, Colors.Red)
End Sub