Android 安卓OpenAL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2587295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:26:11  来源:igfitidea点击:

Android OpenAL?

androidaudioandroid-ndkopenalalsa

提问by Kyle

Has anyone built OpenAL for the Android, or found the shared library for it on the system? This seems like an obvious need for a game of any kind, yet there's no resources out there for it. It seems the Android java sound library can't do pitch changes from what I can tell, so there seems a need for OpenAL. I know OpenAL Soft can be built on top of ALSA, but I'm not sure if anyones done that, and I'm sure it would take me a month.

有没有人为 Android 构建过 OpenAL,或者在系统上找到了它的共享库?这似乎是任何类型游戏的明显需求,但没有可用的资源。似乎Android java声音库无法根据我的说法进行音调变化,因此似乎需要OpenAL。我知道 OpenAL Soft 可以建立在 ALSA 之上,但我不确定是否有人这样做了,而且我确定这需要我一个月的时间。

If there's a good guide somewhere on sound manipulation on the Android without OpenAL, that's fine too. It's just that OpenAL is sort of a standard for game makers and it would be nice to port my thousands of lines over to this system, which I sort of thought was the point of the NDK before I dugg into it and saw that there's almost no shared library access on the system.

如果在没有 OpenAL 的情况下在 Android 上进行声音操作的某个地方有一个很好的指南,那也很好。只是 OpenAL 是游戏制造商的一种标准,将我的数千行代码移植到这个系统会很好,在我深入研究之前,我认为这是 NDK 的重点,发现几乎没有系统上的共享库访问。

Thanks.. I hope I can actually port without becoming a java expert myself. Really disliking the NDK so far!

谢谢.. 我希望我自己可以在不成为 Java 专家的情况下实际移植。到目前为止真的不喜欢 NDK!

回答by AerialX

A few options are available now for NDK audio:

现在有几个选项可用于 NDK 音频:

  1. It's not OpenAL, but OpenSL ES 1.0.1 is an official part of the NDK as of API level 9 (2.3). More information here.

  2. OpenAL Softhas an OpenSL ES backend in its git master (not released as of version 1.13). It is however at this time broken on Android, as it is written for OpenSL ES 1.1, not 1.0.1. See this commitfor a fix.

  3. As mentioned in a previous answer, a JNI backend for OpenAL Soft is linked to and described hereas the only option for OpenAL on pre-2.3 Android platforms. However, this is an outdated fork of OpenAL Soft - I've updated the backend to the latest version on a github repo herealong with the OpenSL ES 1.0.1 fix. Also included is an untested optional patchthat claims to provide better performance and less latency.

  1. 它不是 OpenAL,但从 API 级别 9 (2.3) 开始,OpenSL ES 1.0.1 是 NDK 的官方部分。更多信息在这里

  2. OpenAL Soft在其 git master 中有一个 OpenSL ES 后端(从 1.13 版开始未发布)。然而,此时它在 Android 上被破坏了,因为它是为 OpenSL ES 1.1 而不是 1.0.1 编写的。请参阅此提交以获取修复。

  3. 正如在之前的回答中提到的,OpenAL Soft 的 JNI 后端链接到此处并将其描述为 OpenAL 在 2.3 之前的 Android 平台上的唯一选项。但是,这是 OpenAL Soft 的过时分支 - 我已将后端更新到github 存储库上的最新版本以及 OpenSL ES 1.0.1 修复程序。还包括一个未经测试的可选补丁,声称提供更好的性能和更少的延迟。

回答by Martin

Just before Google announced that 3D audio is going to be included into Android 2.3, I managed to compile OpenAL for Android, and package it as shared object.

就在 Google 宣布 3D 音频将包含在 Android 2.3 中之前,我设法为 Android 编译了 OpenAL,并将其打包为共享对象。

See http://pielot.org/2010/12/14/openal-on-android/

http://pielot.org/2010/12/14/openal-on-android/

Might still be helpful if you'd like to target devices < 2.3.

如果您想定位 <2.3 的设备,可能仍然有帮助。

Cheers.

干杯。

回答by SomeCallMeTim

OpenSL is planned for a future Android build; OpenAL isn't available, and the low-level hardware is off-limits to anything you can do in the NDK, so you can't safely build it yourself.

OpenSL 计划用于未来的 Android 版本;OpenAL 不可用,而且低级硬件禁止您在 NDK 中执行任何操作,因此您无法安全地自行构建它。

There's no support for low-latency audio even planned; there's a bug to that effect here:

甚至没有计划支持低延迟音频;这里有一个错误:

http://code.google.com/p/android/issues/detail?id=3434

http://code.google.com/p/android/issues/detail?id=3434

Star it if it's relevant to you; maybe Google will listen if it gets enough stars.

如果与您相关,请为它加星标;如果获得足够多的星星,谷歌可能会倾听。

EDIT: There IS low latency audio in Android 4.0+, and OpenSL is available now.See this page and linked pages: http://source.android.com/devices/audio/latency.htmlAlso see the NDK guide on OpenSL.

编辑:Android 4.0+ 中存在低延迟音频,并且 OpenSL 现在可用。请参阅此页面和链接页面:http: //source.android.com/devices/audio/latency.html另请参阅 OpenSL 上的 NDK 指南。

回答by CaseyB

You can use the NDK to build OpenAL and package it with your APK. That way you can access it from your native code.

您可以使用 NDK 构建 OpenAL 并将其与您的 APK 打包。这样您就可以从您的本机代码访问它。