Excessive Efficiency Sport Audio with Oboe

Posted by Dan Galpin

High Performance Game Audio with Oboe graphic

We have added the Oboe C++ audio library to the
Android Sport SDK. Oboe’s help of high-performance, low-latency audio throughout the widest vary of Android gadgets is the appropriate selection for many recreation builders.

Single API

On Android gadgets operating Android 8.1 (API degree 27) and better, Oboe takes benefit of the improved efficiency and options of AAudio whereas sustaining backward compatibility (utilizing OpenSL ES) with Android 4.1 (API degree 16) and better. Oboe additionally provides key options on high of the platform APIs to enhance the audio developer expertise, reminiscent of resampling, format conversion, and dynamic latency tuning. It performs audio information transformations, reminiscent of channel depend conversion, when crucial to enhance efficiency on chosen gadgets, and has workarounds for different device-specific behaviors that enhance the robustness of your audio code. In brief, Oboe is now the really useful technique to write audio code in C/C++ on Android.

Integrating Oboe

There are two major methods to include Oboe library prebuilts into your venture. In case you’re utilizing the Android Gradle plugin model 4.1.0 or increased together with CMake, and are utilizing or can allow shared STL, enabling Oboe is as simple as including Oboe to your Gradle dependencies, enabling prefabs, and including a number of traces to your CMakeLists file.

You too can combine Oboe by statically linking utilizing the Android Sport SDK. Start by downloading the library and checking it into your supply management system. You could be utilizing minSdkVersion of 16 or increased with NDK launch 18 or increased. Then, to specify the model of the sport SDK to hyperlink in that is been compiled for the given ABI, API degree, NDK, and STL mixture, add a compiler embrace path on this type:

Instance: gamesdk/libs/arm64-v8a_API24_NDK18_cpp_static_Release

Then add -loboe_static to your linker command. Because you need not bundle the liboboe.so shared library, static linking provides you a smaller code footprint. If the ABI, API degree, NDK, and STL mixture would not have a precompiled model obtainable in your settings, you possibly can alternately hyperlink towards the shared library. We’ve extra steerage, together with configure CMake for static libraries, in our developer documentation.

Oboe Fundamentals

To output audio, you start by making a stream with the required properties, together with a callback that’s used when the stream requires new information.

oboe::AudioStreamBuilder builder;

You will then populate the audio information inside the callback. If the stream creates efficiently, meaning you bought the requested stream sort. In case you did not specify these sorts, you will have to question to see what format was returned.

class MyCallback : public oboe::AudioStreamDataCallback {
    onAudioReady(oboe::AudioStream *audioStream, void *audioData, int32_t numFrames) {
        // We requested AudioFormat::Float
        auto *outputData = static_cast<float *>(audioData);
        // TODO: populate audioData right here
        return oboe::DataCallbackResult::Proceed;

For full particulars on utilizing Oboe, take a look at the documentation, code samples and API reference. There’s even a codelab which reveals you construct a easy rhythm-based recreation.

When you have any points, please file them here. We might love to listen to from you.

Recent Articles

Get enjoying with one of the best video games for PlayStation Now

Supply: Android Central Greatest Video games for PlayStation Now Android Central 2021 PlayStation Now is a large service today, with over 800 games in its library and a few...

Android Studio 4.2

Posted by Jamal Eason, Product Supervisor, Android We're excited to announce that Android Studio 4.2 is now accessible to obtain within the...

Related Stories

Stay on op - Ge the daily news in your inbox