音频库 C++用于多跨平台使用(iphone、android...)
我正在尝试制作一个 C++ 引擎,它将读取 mp3 文件,并根据读取声音文件的时间进行一些图像缩放/翻译。我想我可以使用 OpenGL ES 来渲染我想要的东西,并在我的 C++ 文件中调用一些 OpenGL ES 指令,并在 Obj-C/Java 中初始化我的绘图上下文。我想对声音做同样的事情,但我真的不知道该使用什么,也不知道我是否真的可以在 C++ 中做到这一点。
我搜索了图书馆,所以我找到了 Bass 和 Fmod (这不是免费用于商业用途)。他们说它是多跨平台(Windows、Unix、MacOS),但我不明白它是否适用于移动设备,以及我是否真的可以使用它。有人经历过这个吗?你能给我推荐另一个免费图书馆吗?
再次感谢,我为我糟糕的英语道歉,
阿诺
i'm trying to make a C++ engine that will read a mp3 file, and make some image zoom/translation depending on the time of the reading sound file. I think I could use OpenGL ES to render what I want, and calling some OpenGL ES instructions in my C++ files, and init my drawing context in Obj-C/Java. I want to do the same for the sound, but i don't really know what to use, and if I can really do it or not in C++.
I searched for library so I found Bass and Fmod (which is not free for commercial use). They said it's multicross platform (Windows, Unix, MacOS) but I dont understand if it manners for mobile, and if I can really use it. Does anyone have been through this? Do you recommand me another free library?
Thanks again, and I apologize for my poor english,
Arnaud
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 libpd(嵌入式应用程序的纯数据)
http://download.puredata.info/libpd (该库最近才发布,但代码确实非常成熟)
http://createdigitalmusic.com/2010/10/libpd-put-pure-data-in-your-app-on-an-iphone-or-android-and-everywhere-free/
Have a look at libpd (Pure Data for embedded applications)
http://download.puredata.info/libpd (the library has been released very recently, but the code is very mature indeed)
http://createdigitalmusic.com/2010/10/libpd-put-pure-data-in-your-app-on-an-iphone-or-android-and-everywhere-free/
音频经常是有问题的,编写自己的高级 API 几乎总是一个好主意,该 API 完全可以做您想做的事情(而不是其他事情),并假设您将在它和任何音频之间编写一个薄层您在下面使用的库。如果你很幸运,并且有一个可用的库可以按照你的方式做事,那么这就很简单了。如果没有,至少还是有可能的。无论哪种情况,您的应用程序代码都不会与外部声音 API 绑定。
多年来,我在多个不同的 PC、Mac 和 iPhone 商业项目中使用了 FMOD,并且一直很喜欢它 - 但它不是免费的。我不知道 OpenAL 看起来总是有点笨拙?但您只需在编写 API 层时处理它,而您的应用程序代码永远不需要看到它。
对我来说“编写自己的 API”很容易,因为我已经编写商业游戏 20 年了,所以知道我认为音频 API 应该是什么样子。如果您没有自己的想法,那么我建议您查看对您有意义的第 3 方库,并从中获取您将要使用的功能并编写自己的 API 来实现一组除了调用这些函数之外什么也不做的函数。
由于您可以免费开发 OpenAL 和 FMOD,因此您可以让您的 API 与这两者一起使用,并且很可能它可以与您可能遇到的任何其他内容一起使用。
Audio is often problematic and it is pretty much always a good idea to write your own high-level API that does exactly what you want to do (and nothing else) and to assume you will then be writing a thin layer between it and whatever audio library you are using underneath. If you're lucky and there's a library available that does things the way you would do them then it's trivial. If not, at least it's still possible. In either case, your app code is not tied to an external sound API.
I have used FMOD on multiple different commercial projects over the years for PC, Mac and iPhone, and have always liked it - but it's not free. OpenAL has always seemed sorta, I dunno: clunky? But you only have to deal with it when writing your API layer, and your app code never has to see it.
It's easy for me to say "write your own API" since I've been writing commercial games for 20 years and so know what I think an audio API should look like. If you don't have your own idea how you think it should be, then I suggest you look at a 3rd party library that makes sense to you and take the functions from it that you will be using and write your own API to do be a set of functions that do nothing but call those.
Since you have both OpenAL and FMOD available to you free for development you can then make your API work with both, and chances are it's then going to work with anything else you might come across.
OpenAL 可能是您最好的选择。看看这个答案:Android OpenAL?
似乎可以在Android上编译OpenAL。
OpenAL may be your best bet. Look at this answer: Android OpenAL?
It seems possible to compile OpenAL on Android.
如果您只需要 PCM 音频输入/输出(而不是 MP3 解码),请尝试 PortAudio 或 RTAudio
RtAudio 或 PortAudio,该使用哪一个?
If you are looking for just PCM audio input/output ( and not MP3 decoding ) try PortAudio or RTAudio
RtAudio or PortAudio, which one to use?