Search code examples
iphoneiosaudioringtone

How to convert MP3 audio to m4r on behave of using sound as ringtone?


Within my application I'm using several sounds. I would like the user to have the opportunity to get this sound by means of In-App purchase to enable this sound as a ringtone.

The sounds within my application are of type mp3 and the soundformat for a ringtone is m4r. How can I convert my mp3 soundfile to a m4r? Is there a nice library available or has Apple already got some native ways of doing so?


EDIT: I didn't find a way on converting these mp3 files on the device. However I converted the sound files on my mac to m4a and renamed them to m4r.

I'm also able to play these sounds on my device so I'm happy.


Solution

  • MP3 files are just streaming audio files and M4a and M4r are AAC format files. There is no straight forward single function that excepts your MP3 and gives away an audio in AAC format. AudioStreamingBasicDescription is used to set the various properties of the audio files before you can save them to a file. this consists of varies properties such as mFormatId, mFramesPerPackets, mBytesPerPackets, etc, etc.

    try to have a look at https://developer.apple.com/library/ios/#samplecode/iPhoneExtAudioFileConvertTest/Introduction/Intro.html

    or you can also refer to, http://izotope.fileburst.com/guides/iZotope_iOS_Audio_Programming_Guide.pdf

    I hope this help you. Good Luck.