Frequently Asked Questions (FAQ)

Can I write audio data from Java to Oboe?

Oboe is a native library written in C++ which uses the Android NDK. To move data from Java to C++ you can use JNI.

That said, if you are generating your audio in Java you'll get better performance using the Java AudioTrack class. This can be created with low latency using the AudioTrack.Builder method setPerformanceMode(AudioTrack.PERFORMANCE_MODE_LOW_LATENCY).

You can dynamically tune the latency of the stream just like in Oboe using setBufferSizeInFrames(int) Also you can use blocking writes with the Java AudioTrack and still get a low latency stream. Oboe requires a callback to get a low latency stream and that does not work well with Java.

Note that AudioTrack.PERFORMANCE_MODE_LOW_LATENCY was added in API 26, For API 24 or 25 use AudioAttributes.FLAG_LOW_LATENCY. That was deprecated but will still work with later APIs.

Can I use Oboe to play compressed audio files, such as MP3 or AAC?

Oboe only works with PCM data. It does not include any extraction or decoding classes. For this you can use:

  1. FFmpeg - very fast decoding speeds, but can be difficult to configure and compile. There's a good article on compiling FFmpeg 4.0 here.
  2. The NDK media classes, specifically NdkMediaExtractor and NdkMediaCodec - they're approximately 10X slower than FFmpeg but ship with Android. Code sample here.

If you don't need the lowest possible audio latency you may want to investigate using the following Java/Kotlin APIs which support playback of compressed audio files:

My question isn't listed, where can I ask it?

Please ask questions on Stack Overflow with the Oboe tag.