I have an Android application which uses android.media.SoundPool to play audio cues for the user. It works as expected, but I'd like to be able to add effects to the playback (via android.media.audiofx.AudioEffect subclasses).
I understand how audio effects work on (e.g.) MediaPlayer, but I don't see how to use them with SoundPool. In particular, I'm not sure what to use for the session ID. (I happen to be using Xamarin Android because... reasons. So my example looks weird -- but I'm happy to adapt native Java or Kotlin answers!)
int session = ???; // What goes here?
var fx = new LoudnessEnhancer(session);
fx.SetTargetGain(2400);
fx.SetEnabled(true);
Pool.Play(soundID, 1.0F, 1.0F, 1, 0, 1.00F);
I tried using session ID 0, but (on my WT6000 running Android 7.1.1) it crashes in the LoudnessEnhancer ctor:
Java.Lang.RuntimeException: Cannot initialize effect engine for type: fe3199be-aed0-413f-87bb-11260eb63cf1 Error: -3
(and anyway, my understanding is that applying effects to session ID zero is deprecated).