OpenSL,扮演着不同的声音剪辑,同时与Android NDK? [英] OpenSL, playing different sound clips at the same time with android ndk?

查看:217
本文介绍了OpenSL,扮演着不同的声音剪辑,同时与Android NDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用原生的Andr​​oid NDK和OpenSL ES同时播放多个声音。我已经看到了在NDK的本地音频的例子,但一直没能弄清楚如何来概括它,这样我可以播放不同的音频片段,有可能在同一时间。大部分我已经能够通过,我已经与谷歌取得了最后的50个左右的搜索尝试在网上找到的例子似乎常常依赖于额外的code,如第三方库,是用Java编写的(我正在寻找一个原生解决方案),否则只是似乎并没有被设计来处理多个声音一次。

I am wanting use the native android ndk and OpenSL ES to play multiple sounds simultaneously. I've taken a look at the native-audio example in the ndk but haven't been able to figure out how to generalize it so that I can play different audio clips, possibly at the same time. Most of the examples that I've been able to find online via the last 50 or so search attempts that I've made with google often seem to be dependent on additional code such as a third party library, are written in Java (I am searching for a native solution), or else just don't seem to be designed to handle multiple sounds at once.

如果这有什么差别,以如何处理,对于每一个声音,我想打球,我已经有了一些原始的PCM数据(小端)的内存,准备播放,并为每一个我知道它采样率,每个样品(8或16),和信道数目的位(1或2)。

If it makes any difference to how to approach this, for each sound I am wanting to play, I already have some raw pcm data (little endian) in memory that is ready to be played, and for each one I know its sampling rate, bits per sample (8 or 16), and number of channels (either 1 or 2).

这是任何人都可以提供任何援助将大大AP preciated。 先谢谢了。

Any assistance that anyone can offer would be greatly appreciated. Thanks in advance.

推荐答案

您可以创建多个简单的缓冲队列Audioplayers。你应该有一个机制,知道什么时候该队列播放完毕,所以你可以利用免费的池中。您可以使用回调机制来做到这一点。本机的音频例子讲述这个回调。

You can create multiple simple buffer queue Audioplayers. You should have a mechanism to know when the queue has finished playing so you can utilize free ones from the pool. You can use the callback mechanism to do that. The native-audio example covers this callback.

这篇关于OpenSL,扮演着不同的声音剪辑,同时与Android NDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆