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 units is the proper selection for many sport builders.

Single API

On Android units working Android 8.1 (API stage 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 stage 16) and better. Oboe additionally provides key options on prime of the platform APIs to enhance the audio developer expertise, equivalent to resampling, format conversion, and dynamic latency tuning. It performs audio knowledge transformations, equivalent to channel depend conversion, when essential to enhance efficiency on chosen units, and has workarounds for different device-specific behaviors that enhance the robustness of your audio code. In brief, Oboe is now the really useful method to write audio code in C/C++ on Android.

Integrating Oboe

There are two main methods to include Oboe library prebuilts into your undertaking. Should you’re utilizing the Android Gradle plugin model 4.1.0 or larger 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 can too combine Oboe by statically linking utilizing the Android Sport SDK. Start by downloading the library and checking it into your supply management system. You have to be utilizing minSdkVersion of 16 or larger with NDK launch 18 or larger. Then, to specify the model of the sport SDK to hyperlink in that is been compiled for the given ABI, API stage, NDK, and STL mixture, add a compiler embody path on this kind:

Instance: gamesdk/libs/arm64-v8a_API24_NDK18_cpp_static_Release

Then add -loboe_static to your linker command. Because you needn’t bundle the liboboe.so shared library, static linking provides you a smaller code footprint. If the ABI, API stage, NDK, and STL mixture does not have a precompiled model obtainable to your settings, you possibly can alternately hyperlink in opposition to the shared library. Now we have extra steering, together with the way to 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 knowledge.

oboe::AudioStreamBuilder builder;

You will then populate the audio knowledge inside the callback. If the stream creates efficiently, meaning you bought the requested stream kind. Should you did not specify these varieties, 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 exhibits you the way to construct a easy rhythm-based sport.

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

Recent Articles

Home windows 11 hurts AMD Ryzen efficiency much more than we thought

Home windows 11 might need simply had its Chernobyl second. AMD and Microsoft already confirmed that the brand new working system increases L3 cache...

Twitter testing annoying advert technique with advertisements within the replies

Twitter is getting annoying with the rising variety of advertisements on the platform, particularly on cellular apps. Get able to bad-mouth Twitter much more...

5 greatest video conferencing apps for Android

Conferences are so much simpler than they was once. There weren’t a ton of choices, most of them had been costly, and video high...

Google Sends 50,000 Warnings to Customers Focused by State Hackers

Picture: Kenzo Tribouillard / AFP (Getty Pictures)If the web is a digital Wild West, it’s time to lock your...

Related Stories

Stay on op - Ge the daily news in your inbox