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

One of the best low-cost laptop computer offers in Could 2021

We're bringing you all one of the best low-cost laptop computer offers presently on the cabinets, and proper now you may choose up some...

Oculus replace set to allow spectacular combined actuality seize on iPhone XS and later – 9to5Mac

Oculus is near releasing a brand new replace for its Quest headsets and one of the fascinating new options is Stay Overlay casting. Beforehand,...

Google Developer Scholar Golf equipment in India construct Android Apps with Kotlin

Posted by Siddhant Agarwal, Google Developer Scholar Golf equipment India Neighborhood Supervisor and Biswajeet Mallik, Program Supervisor, Google Builders India ...

Disneyland Paris to Reopen June 17 as Life Will get Extra Regular Because of Vaccinations

The doorway of a vaccination middle in opposition to the coronavirus at Disneyland Paris in Coupvray on April 24, 2021. Photograph: Geoffrey...

Related Stories

Stay on op - Ge the daily news in your inbox