BT

InfoQ Homepage News Oboe, a Library for Low Latency Audio Apps on Android

Oboe, a Library for Low Latency Audio Apps on Android

Bookmarks

Google has released the first production-ready version of Oboe. Oboe is a C++ library for building high performance audio apps on Android, providing the lowest latency possible across 99% of Android devices.

Developers who need to build musical games, audio apps, etc, usually have to deal with latency issues. Oboe aims to address latency issues by providing a simple API that is compatible with API 16+ (Jelly Bean). Under the hood, Oboe takes advantage of the performance and features of AAudio on API 27+ (Oreo MR1) and uses OpenSL ES on API 16+.

AAudio is an Android C API designed for high-performance audio applications that require low latency. It has been introduced in the Android O. Apps communicate with AAudio by reading and writing data to streams.

OpenSL ES on Android is a specific implementation of the OpenSL ES API specification from the Khronos Group. As well the AAudio, this library is designed for high-performance audio applications that require low latency. In addition, OpenSL ES exposes audio features similar to those in the MediaPlayer and MediaRecorder APIs.

To start using Oboe, Android NDK r17 or above is needed. It can be installed via Android Studio SDK manager, or via direct download.

After installed Android NDK r17 or above, clone the GitHub repo and add the following commands to the end of CMakeLists.txt (if you don't have this file, you should add C++ support to the project) file.

cmake_minimum_required(VERSION 3.4.1)

# Build our own native library
add_library (native-lib SHARED src/main/cpp/native-lib.cpp )

# Specify the libraries which our native library is dependent on, including Oboe
target_link_libraries (native-lib log oboe)

# Build the Oboe library
set (OBOE_DIR ../../../oboe)  
add_subdirectory (${OBOE_DIR} ./oboe) 

# Make the Oboe public headers available to our app
include_directories (${OBOE_DIR}/include)

Developers can create an audio stream with a few lines in Oboe:

AudioStreamBuilder builder;
AudioStream *stream = nullptr;
Result result = builder.openStream(&stream);

More details can be found on the documentation, API reference and code sample pages. Furthermore, there is also a codelab where you can build a simple musical game using Oboe; the objective of the game is to copy the clapping pattern you hear by tapping on the screen.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.