播放同时使用OpenSL ES的Andr​​oid几种音效 [英] Play several sound effects simultaneously using OpenSL ES Android

查看:1991
本文介绍了播放同时使用OpenSL ES的Andr​​oid几种音效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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


  

      
  1. 使用多种音频播放器(因此缓冲队列)为再现声音。

  2.   
  3. 混合音效缓冲区整合到一个单一缓冲区,然后排队。

  4.   

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

在此先感谢。


解决方案

我与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:

  1. Use several audio players (and therefore buffer queues) for reproduce the sounds.
  2. 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

这篇关于播放同时使用OpenSL ES的Andr​​oid几种音效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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