I think that I read everything about this problem but haven't found a working answer. So can anybody help with adding reverb to mediaplayer? Here is my code adding PresetReverb
mediaPlayer = MediaPlayer.create(this, R.raw.song)
val presetReverb = PresetReverb(1, 0)
presetReverb.preset = PresetReverb.PRESET_LARGEHALL
presetReverb.enabled = true
mediaPlayer.attachAuxEffect(presetReverb.id)
mediaPlayer.setAuxEffectSendLevel(1.0f)
mediaPlayer.start()
and adding EnvironmentalReverb
mediaPlayer = MediaPlayer.create(this, R.raw.song)
environmentalReverb = EnvironmentalReverb(0, 0)
environmentalReverb.decayTime = 2000
environmentalReverb.reflectionsDelay = 250
environmentalReverb.reflectionsLevel = -8500
environmentalReverb.roomLevel = -8500
mediaPlayer.attachAuxEffect(environmentalReverb.id)
environmentalReverb.enabled = true
mediaPlayer.setAuxEffectSendLevel(1.0f)
mediaPlayer.start()
Also permission was added
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
So I tried using getAudioSessionId(), tried audiosession 0 and 1, both of which didn't create a reverb. When I wrote mediaPlayer.prepare()
, the application crushed. There is no error in Logcat. Maybe there is another method to create reverb?
I found the problem lies in the volume of the player which masks the reverb effect. The solution is to lower the volume of the player to something like 0.5 or even 0.0 then increase global device volume.