fluidsynth/doc/android
2021-02-06 19:28:52 +01:00
..
fluidsynth-assetloader Update Android Asset loader to new callback API 2020-07-12 13:03:30 +02:00
jni Add Android audio drivers based on OpenSLES and Oboe (#464) 2019-03-27 18:02:23 +01:00
.gitignore Add Android audio drivers based on OpenSLES and Oboe (#464) 2019-03-27 18:02:23 +01:00
Makefile.android Speedup Android CI a bit (#769) 2021-02-06 19:28:52 +01:00
oboe-1.0.pc Add Android audio drivers based on OpenSLES and Oboe (#464) 2019-03-27 18:02:23 +01:00
README.md Update and rename README.Android.md to README.md 2020-10-18 11:38:52 +02:00

Android support in Fluidsynth

Fluidsynth supports Android audio outputs by Oboe and OpenSLES audio drivers.

If you are new to Fluidsynth on Android, check out Hector Ricardo's Hello World App for Android.

Android also has Android MIDI API which is exposed only in Android Java API, but it is not exposed as a native API, therefore there is no mdriver support for Android. There is an example MidiDeviceService implementation for Fluidsynth at: https://github.com/atsushieno/fluidsynth-midi-service-j

Usage

libfluidsynth.so and libfluidsynth-assetloader.so are the library that should be packaged into apk. The latter is for asset-based "sfloader".

By default, "oboe" is the default driver for Android. You can also explicitly specify "opensles" instead, with "audio.driver" setting:

fluid_settings_setstr (settings_handle, "audio.driver", "opensles");

Custom SoundFont loader

Since Android file access is quite limited and there is no common place to store soundfonts unlike Linux desktop (e.g. /usr/share/sounds/sf2), you will most likely have to provide custom soundfont loader.

Since version 2.0.0 Fluidsynth comes with fluid_sfloader_set_callbacks() which brings customizible file/stream reader (open/read/seek/tell/close). It is useful to implement simplified custom SF loader e.g. with Android assets or OBB streams.

The Android implementation is in separate library called libfluidsynth-assetloader.so. It comes with native Asset sfloader. However, its usage is a bit tricky because AssetManager needs to be passed from Java code (even though we use AAssetManager API). Use Java_fluidsynth_androidextensions_NativeHandler_setAssetManagerContext() to initialize the this loader, then call new_fluid_android_asset_sfloader() to create a new sfloader. If you already have AAssetManager instance, then the first JNI function is ignorable and you only have to specify the manager to the second function.

There is an example source code on how to do it.

Building

In this directory the Cerbero build system is (ab)used for cross-compiling Fluidsynth's dependencies for Android. The entrypoint is Makefile.android. If you are looking for a step by step introduction guide for cross-compiling Fluidsynth, you'll find it in the wiki.

By default, you are supposed to provide PKG_CONFIG_PATH to glib etc. as well as oboe. There is nothing special.

However, in reality, Oboe does not come up with an official package specification, so you will have to create it manually... unless you use oboe-1.0.pc in this directory as well as the build system set up here.