Open mattkwang opened 3 years ago
Sounds like a good enhancement to me. Oboe is under an Apache 2.0 license? So shouldn't be anything in our way to include it.
Just seconding to say I'd love to see this coming to Godot 4.x! I'm interested in developing music-playing apps with Godot, but haven't been able to achieve Android audio latency shorter than 240ms, which is a dealbreaker for these kinds of applications.
@dvdfu Can you test https://github.com/godotengine/godot/pull/86776 on your project to see if it improves latency?
@dvdfu Can you test godotengine/godot#86776 on your project to see if it improves latency?
Sorry, I hadn't read this reply until now, and it seems like the artifacts are no longer available for download. Happy to test again if they are!
Describe the project you are working on
Godot Audio on Android
Describe the problem or limitation you are having in your project
Godot's audio setup on Android currently uses OpenSL ES, an older audio API supported on Android API 9 and above. This API has high device coverage, but is bulkier and less suitable for low-latency applications compared to the native AAudio API introduced in Android API 26.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Oboe is Android's recommended modern audio API, acting as a C++ wrapper library that chooses between OpenSL ES and AAudio depending on device support and best performance. Oboe is compatible with API 16 onwards (covers 99% of Android devices). We expect this to modernize Godot's audio setup on Android, with lower audio latency and minimal loss of device coverage.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
We will create a class
AudioDriverOboe
housed undergodot/platform/android
, which will take the place ofAudioDriveOpenSL
inOS_Android
. Much of its functionality will mirrorAudioDriverOpenSL
, informed by Oboe's migration guide.Steps:
godot/thirdparty
and link with SCons build system.AudioDriverOboe
with the set of methods inherited fromAudioDriver
, and modifyos_android.h
to use it. More implementation details are available if requested.AudioDriverOboe
Member variables:AudioDriverOboe
Implemented API:For latency testing, the simplest version is the Larsen test with two AudioStreamPlayer nodes, one that records audio input and one that plays the input continuously. By measuring the time between sounds, we capture the sum of input and output latency, with some device/engine overhead. This should serve as an adequate measure for approximate latency improvement.
For testing device coverage, we should have a test app that covers audio features on Godot. This may be using the mic_record demo or some variation upon it which will use both input and output. If run on some device farm or set of devices, we may use app crashes or bad sound behavior to verify minimal loss in coverage.
If this enhancement will not be used often, can it be worked around with a few lines of script?
N/A. This is expected to be used for all Godot games exported for Android.
Is there a reason why this should be core and not an add-on in the asset library?
This proposal changes the audio (a core element of the engine) intending to impact all games for the Android platform.
Android Games DevTech Team @ Google