iPhone SDK:是否可以处理本地库中的音频文件
好吧,我会尽力不让它成为一个“我只想要代码”的问题...
我最近正在开发一个项目,该项目需要对本地音乐文件(例如 iTunes 库)进行一些音频信号处理。整个工作包括:
- 获取音频文件的PCM数据(通常来自iTunes库); <--AudioQueue(?)
- 将PCM数据写入新文件(苹果似乎不允许直接修改音乐曲目); <--CoreAudio(?)
- 做一些处理和修改,如过滤器、操纵器等。 <-- 将用C++开发
- 播放处理后的曲目。 <--RemoteIO
问题是,在浏览了一些博客和讨论之后:
http://lists.apple.com/archives/coreaudio-api/2009/Aug/msg00100.html,http://atastypixel.com/blog/using-remoteio-audio-unit/
http://osdir.com/ml/coreaudio-api/2009-08/msg00093.html
以及官方示例代码,我感觉 CoreAudio SDK 允许我们仅对从麦克风录制的语音演示应用音频处理。
我的问题是:
- 我可以从 iTunes 库曲目而不是麦克风输入获取原始数据吗?
- 如果第一个问题是“否”,有没有办法“欺骗”SDK,让它认为它是从麦克风输入获取数据,而不是从 iTunes 获取数据? (我之前在 C# 中做过一些类似的“黑客”工作 XD)
- 如果整个处理不起作用,任何人都可以提供一些替代想法吗?
任何帮助将不胜感激。非常感谢:-)
谢谢。
Well, I will try best not to make it as a 'I just want the code' question...
I'm recently working on a project which requires some audio signal processing from local music files (e.g. iTunes Library). The whole work includes:
- Get the PCM data of an audio file (normally from iTunes library); <--AudioQueue (?)
- Write the PCM data to a new file (it seems that Apple does not allow direct modification on music tracks); <--CoreAudio(?)
- Do some processing and modification, like filters, manipulators, etc. <-- Will be developed in C++
- Play the processed track. <--RemoteIO
The problem is, after going through some blogs and discussions:
http://lists.apple.com/archives/coreaudio-api/2009/Aug/msg00100.html, http://atastypixel.com/blog/using-remoteio-audio-unit/
http://osdir.com/ml/coreaudio-api/2009-08/msg00093.html
as well as the official sample codes, I got a feeling that the CoreAudio SDK allow us to apply audio processing only on voice demos recorded from Mic.
My question is that:
- Can I get raw data from iTunes library tracks instead of Mic input?
- If the first question is 'No', is there a way to 'fool' the SDK to let it think it is getting data from Mic input, not from iTunes? (I have done some similar 'hacking' stuff in C# before XD)
- If the whole processing just doesn't work, can anyone provide some alternative ideas?
Any help will be appreciated. Thank you very much :-)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
昨天刚发现一些很酷的东西。
从 iPhone 媒体库到 PCM 样本,需要经过数十个令人困惑、可能有损的步骤
(http://www .subfurther.com/blog/?p=1103
还有 MIT 的类库:
TSLibraryImport:Objective-C 类 + 用于在 iOS4 中从用户的 iPod 库导入文件的示例代码
(http://bitbucket.org/artgillespie/tslibraryimport/changeset/a81838f8c78a
希望他们有所帮助!
干杯,
曼卡
Just found something really cool yesterday.
From iPhone Media Library to PCM Samples in Dozens of Confounding, Potentially Lossy Steps
(http://www.subfurther.com/blog/?p=1103
And also a class library by MIT:
TSLibraryImport: Objective-C class + sample code for importing files from user's iPod Library in iOS4.
(http://bitbucket.org/artgillespie/tslibraryimport/changeset/a81838f8c78a
Hope they help!
Cheers,
Manca
1) 不可以。Apple 不允许直接访问歌曲的 PCM 数据。否则你可以创建音乐共享应用程序,这不符合苹果的利益。
2) 不可以。由于Apple 的代码审批机制,黑客攻击和获得批准是不可能的。
3)我能想到的唯一选择是你必须在PC/Mac上完成处理部分,然后将其传输到iPhone。或者您必须将文件存储在您自己的应用程序文件夹中 - 您应该能够通过 CoreAudio 加载和处理这些文件。
1) No. Apple does not allow direct access to PCM data of songs. Otherwise you could create music-sharing apps, which is not in Apple's interests.
2) No. Hacking and getting approved is impossible due to Apple's code approval mechanism.
3) The only alternative I could think of is that you have to do the processing part on PC/Mac and then transfer it to the iPhone. Or you would have to store the files in your own applications folder - you should be able to load and process these via CoreAudio.
我知道这个线程很旧但是...这对你有用吗,曼卡?这个应用程序获得批准了吗?
编辑:刚刚发现了自 iOS 4.1 以来引入的 AVAssetReader 类,应该会有所帮助
I know this thread is old but... did this work for you, Manca? And did this app get approved?
EDIT: just discovered the AVAssetReader class, introduced since iOS 4.1, should help