Android Question How to set LoudnessEnhancer on SimpleExoPlayer ?

Caps64

Member
I am trying to boost the volume of the SimpleExoPlayer using the LoudnessEnhancer AudioEffect:
B4X:
Sub JAUDIO_Event (MethodName As String, Args() As Object) As Object
    Log(MethodName)
    If MethodName = "onAudioSessionId" Then
        AudioSessionID = Args(0)
        Log("AudioSessionID: " & AudioSessionID)
      
        Dim level As Int = 20
        Dim job As JavaObject
        Dim jLoudness As JavaObject = job.InitializeNewInstance("android.media.audiofx.LoudnessEnhancer", Array(AudioSessionID))
        jLoudness.RunMethod("setTargetGain", Array(level*100))
        Log("Loudness level: " & jLoudness.RunMethod("getTargetGain", Null))
   End If
   Return Null
End Sub

I get the JAUDIO_Event and the AudioSessionID, I dont get any error on creation of the AudioEffect instance and setting the gain level, but it does nothing, no effect at all, with all the values I tried for the gain level (it is in mB, 100mB=1dB).
What is the problem, why it does not work?
 

Caps64

Member
Thanks Erel.
I found what it was missing:
B4X:
    jLoudness.RunMethod("setEnabled", Array(True))
Then I also had to make jLoudness a global variable as you suggested, in order to keep the effect working.
 
Upvote 0
Top