tags:

views:

1890

answers:

4

Hello,

As of right now I am using ffmpeg to convert from .mp3 --> to .aiff but I would like a native way to do this in xcode but i do not understand how to use AudioConverter.h in AudioToolbox soo if someone could please help me I would be really appreciative.

Thank You Enea

+1  A: 

I think the real question is why would you want to? The iphone and AudioQueue has full mp3 support for playback and mixing. I know of no way to do this on the fly in the iPhone. It is a fairly processor intensive task and I doubt you could do it efficiently on the iPhone anyway.

coneybeare
The reason I am trying to do this is beacuse my app downloads files in .m4r/.mp3 and for my purposes i need them in .caf and i was wondering if there is any way to instead of supplying a recording as packets to the speakhere example when it writes data to the file that is create if you could pass data from an mp3 file?
Enea
I suggest you look up apple docs or search on Stack Overflow as how to play a sound. The speakhere example is a little old, and newer, easier methods are available
coneybeare
+1  A: 

You can use ExtAudioFile to open and convert the file to CAF with PCM data.

lucius
A: 

Lucius can you please give me some more details i have not worked with sound that much and cannot seem to find any tutorials online

Enea
+2  A: 

ExtAudioFile can do a fantastic job of this. One reason to take some compressed formats like MP3 and convert to PCM is that there is much less of a latency when playing the sound. An MP3 sound effect, for example, can take close to a second to start playing back, when the same sound in PCM could start almost immediately. I know since I am converting my sounds to PCM at launch time and eliminating the delays I was plagued with.

Go download iPhoneExtAudioFileConvertTest and you will find everything you need to do your own conversions

mahboudz
If latency is not an issue, then skip conversion and use AVAudioPlayer to play your MP3s.
mahboudz