quano
quano

Reputation: 19152

Mixing sound files on an iPhone

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.

Upvotes: 6

Views: 2625

Answers (3)

slf
slf

Reputation: 22777

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?

Upvotes: 2

Fred
Fred

Reputation: 459

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.

Upvotes: 3

Piotr Czapla
Piotr Czapla

Reputation: 26552

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

Upvotes: 0

Related Questions