如何使用低延迟的Android音频 [英] How to use Android audio with low latency

查看:590
本文介绍了如何使用低延迟的Android音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

您可能已经听说过,Android不提供低延迟音频API.低延迟音频的意思是,您应该能够从麦克风获取音频信号并播放声音,而两者之间没有太多时间间隔(例如5-7毫秒)

As you might have heard, Android does not provide with low latency audio API. What I mean by low latency audio is that you should be able to get audio signals from microphone and play the sound without much time gap in-between (e.g., 5-7 ms)

我尝试使用旧的Java(带有AudioRecord和AudioTrack)和新的" OpenSL ES.它们很糟糕,使应用程序无法使用.此问题在此处已得到详细记录.顺便说一句,iOS API可以产生大约5-7毫秒的延迟.

I've tried old java (with AudioRecord and AudioTrack) and "new" OpenSL ES. They are terrible and make app unusable.The issue was well documented here. BTW, iOS API can produce about 5-7 ms latency.

寻找解决方法:

但是我还是想做低延迟的音频. 类似此答案的内容.

But I am trying to do the low latency audio anyway. Something like this answer describes.

但是,我只能通过写我的书才能令人满意地实现这一目标. 自己的代码,在内部进行混合并访问底层 音频播放API仅用于播放最终的混合输出.这 .Net Compact Framework中播放声音的高级方法是 理论上可以复音,但实际上它们工作得很糟糕 (许多小故障,卡结和失真)."

"However, I was only able to achieve this satisfactorily by writing my own code that did the mixing internally and accessed the low-level audio playback API only for playing the final mixed output. The higher-level ways of playing sounds in the .Net Compact Framework are theoretically capable of polyphony, but in practice they work horribly (lots of glitches, stuttering and distortion)."

这对Android有意义吗? 答案令人沮丧.

Does this make sense for Android? An answer is discouraging.

所以我的问题.真的无法通过Android实现10毫秒的音频延迟吗?

So my question. Is there really no way to achieve 10 ms audio latency with Android?

说实话,我不希望很快找到解决方案,而只是希望一个伟大的头脑能回答这个问题.

To be honest, I am not expecting a solution in some time soon but just wish one great mind have answer to this problem.

推荐答案

android 4.1+具有低延迟音频api,应该为您提供低于10ms的延迟.但是其价值因硬件而异(欢迎使用丰富多样的android系统).

android 4.1+ has low latency audio api which should give you below 10ms latency. however the value varies by hardware (welcome to rich diverse world of android).

"android.hardware.audio.low_latency"功能描述符也可用于过滤出缺少低延迟支持的设备.

also feature descriptor of "android.hardware.audio.low_latency" can be used for filter out devices lacking low latency support.

签出 http://www.youtube. com/watch?v = Yc8YrVc47TI& feature = player_de%20tailpage#t = 1366s

以及以下内容: 查看全文

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