播放两种声音Simutaneosly [英] Playing two sounds Simutaneosly

查看:174
本文介绍了播放两种声音Simutaneosly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在android.I simutaneosly发挥两个声音已经创建了两个MediaPlayers和现在用的是code below.They another.Or后,当前正在播放的一个又一个不完全是一个,但有点推迟到海誓山盟。

I am trying to play two sounds simutaneosly in android.I have created two MediaPlayers and am using the code below.They are currently playing one after another.Or not exactly one after another but kinda delayed into eachother.

private void playSound(){
       if (mp1 != null) {
           mp1.release(); 
        }
       if (mp2 != null) {
            mp2.release(); 
         }


        mp1 = MediaPlayer.create(this, soundArray[0]); 
        mp2 = MediaPlayer.create(this, soundArray[3]);
        mp1.start();
        mp2.start();

      }

感谢

推荐答案

同时播放两路数字声音就是这么简单相加在一起(如在现实世界中),所以你可以做自己,而填充缓冲区(和有控制时间)。

Playing two digital sounds simultaneously is as simple as summing them together (as in the real world), so you could do that yourself while filling the buffer (and have control over timing).

这可能会导致幅度提高,因此应注意不要超过数组类型的数值范围,如果你不希望引起削波假象。

This could cause the amplitude to raise, so care should be taken to not surpass the numeric bounds of the array type if you don't want to cause clipping artifacts.

​​这个问题,并回答也可能会有所帮助。

这篇关于播放两种声音Simutaneosly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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