在 iPhone 上混合声音文件
我有几个 wav 文件,可能还有一个 mp3,我想将它们混合成一个 wav 或 mp3 文件。我正在使用 C/C++/Obj-C (iPhone)。我对这类事情确实没有经验。如果有人能给我一些指示,我将非常感激。
基本上我想做的是类似的事情,例如 Audacity 可以做的事情,但是以编程方式进行。是否没有一个声音库,您可以轻松地打开音频文件并将它们“粘贴”到新文件中的指定位置?哪里混合是您不必担心的事情?
谢谢。
I've got a couple of wav files and possibly a mp3 that I'd like to mix down to a single wav or mp3-file. I'm using C/C++/Obj-C (iPhone). I have really no experience with this sort of thing. If anyone could give me some pointers, I would be very grateful.
Basically what I want to do is similar things like for example Audacity can do, but programmatically. Isn't there a sound library where you can easily open audio files and "paste" them into a new one at defined positions? Where mixing is something you don't have to worry about?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
混合线性 PCM 的两个声音缓冲区只需将它们中的每个样本值相加即可,当然要确保不会溢出。通常,您会在缓冲区中使用浮点值,因此问题出在您返回文件时。您还应该在 iPhone 上使用 CoreAudio,它具有打开/读取/写入不同格式的声音文件的所有方法。我认为 iPhone 上还有一个 mac 上没有的更高级的 api,请查阅苹果文档。
Mixing two sound buffers of linear PCM is only a matter of adding each sample value in them together, and of course make sure you don't overflow. Normally you would use floating point values in the buffers though, so the issue is when you go back to the file. You should also have CoreAudio available on the iPhone, it has all the means to open/read/write sound files in different formats. I think there is also a more high level api available to the iPhone that isn't on the mac, look up the apple docs.
如果您专门寻找 Audacity 的功能,它在底层使用 PortAudio (看起来像 MIT 许可证) )。也许你可以尝试使用它?
If you are specifically looking for the features of Audacity, it uses PortAudio under the hood (looks like an MIT license). Perhaps you can just try to use that?
首先阅读多媒体支持点它包含很多信息。以下是摘录:
iPhone 上有 3 种混合音频的方法:
另请检查以下示例出: iPhoneMultichannelMixerTest< /a>:
Read Multimedia support as a starting point it contains alot info. Here is an extract:
There are 3 ways to mix the audio on iphone:
Also check the following sample out: iPhoneMultichannelMixerTest: