Developer
Developer

Reputation: 6465

How to mix two mp3 files in and generate one in iPhone app

I have two mp3 files, a.mp3 of 5 seconds and b.mp3 of 7 seconds and I want to mix them in order to generate c.mp3 of duration 7 secs. I have tried the following code Example 4 of the following link http://www.modejong.com/iOS/#ex4

but it mixes only caf files and I need to mix the MP3 files of different sizes.

Thanks-

Upvotes: 1

Views: 884

Answers (2)

Paras Joshi
Paras Joshi

Reputation: 20551

Here for your requirement you can use this bellow demo code with convert two .mp3 or caf file to one file , see the tutorial and get some idea and also use these Demos ..

Please see this bellow links with sample codes and tutorials..

  1. AudioConverterFileConvert

  2. iPhoneExtAudioFileConvertTest

i hope this help you...

Upvotes: 1

Midhun MP
Midhun MP

Reputation: 107231

You need to use AVMutableCompositionTrack and AVAssetExportSession Class to do it.

Here is a sample code on developer.Apple.com.

This is a nice tutorial which merge two video files and one music file into a single file. This same code can be reused to merge two audio files.

Upvotes: 3

Related Questions