Android Question Noise Suppression

Gandalf

Member
Licensed User
Longtime User
B4X:
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

I have tried it - despite it shows Available and Enabled as true, I didn't notice any significant effect.
 
Upvote 0

Philip Prins

Active Member
Licensed User
Longtime User
B4X:
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

I have tried it - despite it shows Available and Enabled as true, I didn't notice any significant effect.
Thanks,

Tried it and no effect on the audio
 
Upvote 0
Top