我应该使用哪种框架在iOS中以低延迟播放音频文件(WAV,MP3,AIFF)? [英] Which framework should I use to play an audio file (WAV, MP3, AIFF) in iOS with low latency?

查看:117
本文介绍了我应该使用哪种框架在iOS中以低延迟播放音频文件(WAV,MP3,AIFF)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS具有各种音频框架,从较高的级别允许您简单地播放指定的文件,到较低的级别可以使您获取原始PCM数据,以及介于两者之间的所有内容。对于我们的应用程序,我们只需要播放外部文件(WAV,AIFF,MP3),但是我们需要响应按下按钮来播放,并且我们需要使延迟尽可能小。 (用于在现场制作中排队。)

iOS has various audio frameworks from the higher-level that lets you simply play a specified file, to the lower level that lets you get at the raw PCM data, and everything in between. For our app, we just need to play external files (WAV, AIFF, MP3) but we need to do so in response to pressing a button and we need that latency to be as small as possible. (It's for queueing in live productions.)

现在,AVAudioPlayer可以播放简单的文件资产(通过其URL),但是实际上启动声音的延迟是太好了对于长度超过五分钟的较大文件,开始播放声音的延迟可能会超过一秒钟,这使它几乎不能用于现场表演的计时。

Now the AVAudioPlayer and such work to play simple file assets (via their URL), but its latency in actually starting the sound is too great. With larger files of more than five minutes in length, the delay to start the sound can be over a second long which renders it all but useless for timing in a live performance.

现在我知道像openAL这样的东西可以用于非常低延迟的播放,但是随后您就陷入了音频缓冲区,音频源,听众等的困境。

Now I know things like openAL can be used for a very-low-latency playback, but then you're waist-deep into audio buffers, audio sources, listeners, etc.

也就是说,有谁知道在延迟较低的较高级别(例如播放 MyBeddingTrack.mp3)上工作的任何框架吗?预先缓冲就可以了。

That said, does anyone know of any frameworks that work at a higher-level (i.e. play 'MyBeddingTrack.mp3') with a very low latency? Pre-buffering is fine. It's just the trigger has to be fast.

如果我们可以做一些事情,例如在文件中设置播放的起点和终点,或者更改音量或甚至执行回避等等。

Bonus if we can do things like set the start and end points of the playback within the file, or to change the volume or even to perform ducking, etc.

推荐答案

包含使用音频单元(特别是AudioFilePlayer)播放文件的工作代码。即使问题指出它无法正常工作,但它对我来说都是开箱即用的-仅在末尾添加 AUGraphStart(_graph)

AudioFilePlayer的'ScheduledFilePrime'属性说明在开始播放之前要加载多少文件。您可能想尝试一下。

The 'ScheduledFilePrime' property of the AudioFilePlayer states how much of the file to load before starting to play. You may want to play around with that.

但是正如其他人所指出的,音频单元的学习曲线很陡。

But as the others note, Audio Units have a steep learning curve.

这篇关于我应该使用哪种框架在iOS中以低延迟播放音频文件(WAV,MP3,AIFF)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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