iOS高级音频API用于解压缩格式
在iOS上,是否可以以解压缩格式获取用户的音频流?例如,MP3 作为可用于音频分析的 WAV 返回?我对 iOS 平台比较陌生,我记得在旧的 iOS 版本中这是不可能的。我读到 iOS 4 引入了一些高级 API,但我不确定在哪里可以找到这些的文档/示例。
On iOS, is it possible to get the user's audio stream in a decompressed format? For example, the MP3 is returned as a WAV that can be used for audio analysis? I'm relatively new to the iOS platform, and I remember seeing that this wasn't possible in older iOS versions. I read that iOS 4 brought in some advanced APIs but I'm not sure where I can find documentations/samples for these.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不介意使用适用于 iOS 4.1 及更高版本的 API,您可以尝试使用
AVAssetReader
类和朋友。 在这个类似的问题中,您有一个有关如何提取视频帧的完整示例。我希望同样的方法也适用于音频,而且好处是读者可以处理解压缩的所有细节。您甚至可以使用 AVComposition 进行合成来合并多个流。这些类是 AVFramework,它不仅允许阅读,还可以创建您自己的内容。
If you don't mind using API for iOS 4.1 and above, you could try using the
AVAssetReader
class and friends. In this similar question you have a full example on how to extract video frames. I would expect the same to work for audio, and the nice thing is that the reader deals with all the details of decompression. You can even do composition withAVComposition
to merge several streams.These classes are part of the AVFramework, which allows not only reading but also creating your own content.
Apple 在 http://developer.apple 中有一个 OpenAL 示例.com/library/mac/#samplecode/OpenAExample/Introduction/Intro.html 您应该对 Scene.m 感兴趣。
Apple 文档有这张图片其中 Core Audio 框架清楚地表明它可以为您提供 MP3 输出。它还 声明您可以访问音频单元如果您需要的话,以更激进的方式。
同一个 Core Audio 文档还提供了一些有关使用 MIDI 的信息(如果它可以帮助您)。
编辑:
您今天很幸运。
Apple has an OpenAL example at http://developer.apple.com/library/mac/#samplecode/OpenALExample/Introduction/Intro.html where Scene.m should interest you.
The Apple documentation has this picture where the Core Audio framework clearly shows that it gives you MP3 out. It also states that you can access audio units in a more radical way if you so need.
The same Core Audio document gives also some information about using MIDI if it may help you.
Edit:
You're in luck today.
在 此示例中,加载并馈送音频文件到 AudioUnit 图中。您可以相当轻松地编写自己的 AudioUnit 并将其放入该图中,并根据您认为合适的方式分析 PCM 流。您甚至可以在回调函数中执行此操作,尽管这可能不是一个好主意,因为鼓励回调尽可能简单。
In this example an audio file is loaded and fed into an AudioUnit graph. You could fairly easily write an AudioUnit of your own to put into this graph and which analyzes the PCM stream as you see fit. You can even do it in the callback function, although that's probably not a good idea because callbacks are encouraged to be as simple as possible.