We’ve recently committed a new audio renderer for Android that is based on OpenAL Soft. This new renderer very closely mimics the desktop OpenAL audio renderer so you should now be able to have the same audio effects as desktop like adjusting pitch, setting the reverb and environment, etc. It also supports audio files in the assets.jar file or in the Android project assets directory.
The new audio renderer uses Android’s OpenSL audio implementation, but Android didn’t start including it until Android 2.3 (version 9). Therefore, this new renderer will not work on devices running on Android 2.2, which is the current target for jME3.
Known Issues:
- Only wav and ogg audio files are supported (not mp3)
- If you stream ogg files, there is a lot of GC going on
- Make sure there is no extra data in the audio file like track name, artist, etc… Audio does not play if there is any extra data.
If you feel up to it, you can try it out and let us know if you have any issues. It will remain optional and experimental until after jME 3.0 releases since it will raise the minimum Android version supported by jME3. We also need some time to make sure it is working completely before switch the main audio renderer to this one.
To try it out, you need to do the following:
- Update to the latest SVN / Nightly version of the engine
- Add the jME3-openal-soft-natives-android.jar library to your android project. It is located in the /engine/lib/openal-soft directory (or the /engine/dist/opt/native-openal-soft directory after you build the engine). Do not copy it to the android project libs directory because it gets deleted and repopulated each time you hit Play in the SDK.
- Add the following line to your MainActivity.java file in the Android project
[java]audioRendererType = AppSettings.ANDROID_OPENAL_SOFT;[/java]
audioRendererType is a new variable in AndroidHarness that is used to switch the android audio renderer. The default is AppSettings.ANDROID_MEDIAPLAYER which uses the current audio renderer.
This is still experimental, so use at your own risk, but we would appreciate any feedback you have.