开发者

Mixing sound files on an iPhone

开发者 https://www.devze.com 2022-12-27 16:50 出处:网络
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 anyo

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 "开发者_StackOverflow中文版paste" them into a new one at defined positions? Where mixing is something you don't have to worry about?

Thanks.


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.


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?


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:

  • Audio Unit framework
    • Multichannel Mixer - "lets you mix multiple audio streams to a single stream"
    • 3D Mixer unit - "lets you mix multiple audio streams, specify stereo output panning, manipulate sample rate"
  • OpenAl used in games development

Also check the following sample out: iPhoneMultichannelMixerTest:

Two input busses are created each with input volume controls. An overall mixer output volume control is also provided and each bus may be enabled or disabled

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号