2

I have the simple problem here. I have two CAF files. All I want to do is to join them to be one long audio file.

I've tried to:

  • Use the NSData class and append the audio data of both files into one. Hasn't worked. I assume some file property is not being set properly. The resulting file only plays the length of the first file.

  • Tried to set the kAudioFilePropertyAudioDataByteCount property of the resulting file in my joining process. No result.

Could anyone point me in the right direction / help me with some sample code? I have seen other people asking similar questions and going unanswered. Hoping someone would pick this up.

Your help is greatly appreciated. Thanks.

dineth
  • 9,822
  • 6
  • 32
  • 39

1 Answers1

0

If anyone is keen to know the answer, there is a way to do it. You have to use the AudioFiles API calls. Basically, you'd:

  • create a new audio file using AudioFileCreate with the correct parameters (bitrate etc).
  • open your first file, read the packets and write them to the newly created file.
  • open your second file and do the same. make sure your counters are not zero-ed out after writing the first file.
  • AudioFileClose -- and you're done!

Things to note: for local files, you have to run a method to escape spaces

That's about it!

dineth
  • 9,822
  • 6
  • 32
  • 39
  • Does this really work with .caf file? I think it can work only with stream media file like .mp3 – Ketan Bhavsar Sep 16 '13 at 12:47
  • I actually got this working couple of years ago. I opened up couple of CAF files and joined them in iOS. I do apologise for not having the source code still lying around to post. – dineth Sep 17 '13 at 00:45