播放同时使用OpenSL ES的Andr​​oid几种音效几种、音效、ES、OpenSL

由网友(硬汉无敌)分享简介:我使用OpenSL ES播放音乐,并在我的项目的声音。我使用的本机的音频采样的开始和它的罚款重现背景音乐和一个声音,但是当我试图在同一时间重现两个或更多的声音的声音不能同时再现,因为声音缓冲区排队等待播放时,所有的previous缓冲区播放。于是,一个小小的研究后的我发现了两种方法来解决这个问题,简称:    使用多种...

我使用OpenSL ES播放音乐,并在我的项目的声音。我使用的本机的音频采样的开始和它的罚款重现背景音乐和一个声音,但是当我试图在同一时间重现两个或更多的声音的声音不能同时再现,因为声音缓冲区排队等待播放时,所有的previous缓冲区播放。

于是,一个小小的研究后的我发现了两种方法来解决这个问题,简称:

    使用多种音频播放器(因此缓冲队列)为再现声音。  混合音效缓冲区整合到一个单一缓冲区,然后排队。  

我的问题是:你认为什么是最好的方法?还有,我已经忽略了一个更好的办法?

在此先感谢。

解决方案

我与OpenSL ES工作为好。有点复杂唉开始......

反正你可以创建多你ObjectPlayer,永远记住,对象的最大ammount的是32。

所以,理想情况下,如果你要玩4的声音的同时,你需要4 PlayerObject和1 OutputMixObject

希望你能找到有用的。

I'm using OpenSL ES for playing music and sounds in my project. I've used native-audio sample as start and it's fine for reproduce background music and a single sound but when I try to reproduce two or more sounds at same time the sounds aren't reproduced simultaneously because the sound buffers are enqueued for playback when all previous buffers are played.

Then, after a little research, I've found two ways to fix it, in short:

Use several audio players (and therefore buffer queues) for reproduce the sounds. Mix the sound effects buffers together into a single buffer and then enqueue.

My questions are: What do you think is the best approach? There's a better way that I've ignored?

Thanks in advance.

解决方案

I'm working with OpenSL ES as well. Little bit complicated ay the beginning...

Anyway you can create as much ObjectPlayer you want, always remember that the maximum ammount of objects is 32.

So, ideally, if you want to play 4 sounds at the same time, you need 4 PlayerObject and 1 OutputMixObject

Hope you can find usefull

阅读全文

相关推荐

最新文章