音频在iPhone [英] Audio on the iPhone

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

问题描述

我在找创建模拟物理仪器的应用程序。我有音频采样,但我希望能够动态地增加俯仰/频率,所以我不必从太多的文件加载。

I'm looking to create an app that emulates a physical instrument. I've got audio samples but I want to be able to increase the pitch/frequency dynamically so I don't have to load from too many files.

任何想法,哪些音频API将能够做到这一点?我认为无论是OpenAL的或音频队列服务,但我不知道这是合适的。任何链接到引导/样品code也更AP preciated。

Any idea which audio API will be able to do this? I reckon either OpenAL or Audio Queue Services but am not sure which is suitable. Any links to guides/sample code is also much appreciated.

先谢谢了。

推荐答案

我这条路去了,2009年,努力音频工具包,音频队列服务,OpenAL的,最后定居在RemoteIO AudioUnit。

I went down this road in 2009, trying Audio Toolkit, Audio Queue Services, openAL, and finally settling on the RemoteIO AudioUnit.

音频工具箱是罚款,基本触发声音效果,但它无法改变频率或循环样本。

Audio Toolbox is fine for basic triggered sound effects, but it wasn't able to change frequencies or loop samples.

音频队列服务可以循环样品,但我能找到调整样本的回放频率的唯一办法是重新从文件中读取数据 - 非常痛苦。此外,该框架是极其繁琐 - 我只使用它,如果我试图流东西从互联网

Audio Queue Services can loop samples, but the only way I could find to adjust the playback frequency of a sample was to re-read the data from the file -- very painful. Plus, the framework is tremendously cumbersome - I'd only use it if I was trying to stream something off the Internet.

OpenAL的是一个天赐良机 - 在一小时之内启动并运行它,让我的手后,没有再可用 - 从苹果在crashlandingiPhone示例应用程序。我发现OpenAL的是非常适合于游戏,甚至是乐器 - 样品可能是pre装,调整频率很容易,循环是没有问题的。该交易断路器对我来说是启动和停止的环样品将导致几乎每一次一个讨厌的流行。同时内置的3D定位音频混合器是有点太CPU密集型的,我喜欢。

OpenAL was a godsend - was up and running with it in under an hour, after getting my hands on the no-longer-available-from-Apple "CrashLanding" iPhone sample app. I found OpenAL to be ideally suited to games or even a musical instrument -- samples could be pre-loaded, adjusting the frequency was easy, and looping was no problem. The deal-breaker for me was that starting and stopping a looped sample would result in a nasty "pop" almost every time. Also the builtin 3d positional audio mixer was a bit too CPU-intensive for my liking.

如果您的仪器不使用环形样品,我建议首先尝试OpenAL的路线 - 学习曲线恐吓要少得多。尝试追查SoundEngine.h,在crashlanding或TouchFighter,或查看以下链接:

If your instrument does not use looped samples, I'd suggest trying the OpenAL route first - the learning curve is much less intimidating. Try to track down "SoundEngine.h", "CrashLanding" or "TouchFighter", or check out the following link:

http://benbritten.com/blog / 2008/11/06 / OpenAL的声音 - 上的-iphone /

由于环形样品对我的要求,我终于选定了AudioUnits(其中,在i​​Phone上,被称为RemoteIO如果你想要做的输入或输出)。这是极其难以实施 - 非常相似,音频队列服务,在你执行的​​核心将是一个缓冲回调里面,被称为每秒钟数次,以填补原SInt16值出境音频的缓冲

Since looped samples was a requirement for me, I finally settled on AudioUnits (which, on the iPhone, is referred to as "RemoteIO" if you want to do input or output). It was tremendously difficult to implement - very similar to Audio Queue Services, in that the core of your implementation will be inside a "buffer callback", being called several times per second to fill a buffer of outbound audio with raw SInt16 values.

最后,我得到了我的乐器多复音工作精美,环样品,不爆裂,而且延迟时间最短。

Ultimately, I got my instrument working beautifully with multi-note polyphony, looped samples, no popping, and minimal latency.

不幸的是,RemoteIO没有详细的记载。迈克尔·泰森是在该领域的第一次写关于RemoteIO的长度之一,他的文章(和评论)是非常有用的对我说:

Unfortunately, RemoteIO is not well documented. Michael Tyson was one of the first in the field to write about RemoteIO at length, and his posts (and the comments) were very useful to me:

http://michael.tyson.id .AU / 2008/11/04 /使用-remoteio音频单元/

祝你好运!

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

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