IPhone - convert mp3 to wav?

Is there any way to convert mp3 file to wav / aiff in iPhone app? I have mp3, but I want to combine it with other files, and the only way to find out what can be done is to use PCM formats.

Can someone help me here?

Thanks.

Some things I tried

I tried using the AudioConverterFillComplexBuffer () method and its callback to convert mp3 to caf, but the bytes for each packet and each frame are considered 0. Any ideas how I can or can I use this function?

Thanks again.

+4
source share
2 answers

WAV and AIFF often (usually?) Contain PCM, so what is the objection? Or you say that you need to get your MP3 data in PCM in order to mix it (possibly in a multi-channel mixer audio system). If you really want it, take a look at Core Audio, in particular:

  • Audio File Services (for reading MP3 format and recording AIFF or WAV)
  • Audio file conversion services (for converting MP3 data to PCM and / or for encoding from PCM to some other codec, if you were to record the file). Please note that this converter cannot convert between two encoded formats; you can make MP3-PCM or PCM-AAC, but you need two converters to work with MP3-AAC.
  • Advanced audio file services that combine both of the above.

Check out the ConvertFile example in the Core Audio SDK. This opens the source file for reading, describes the desired format of the target file, reads buffers from one and writes them to another. The code demonstrates both the separate use of file services + conversion services, and the convenient use of ExtAudioFiles.

Also, be sure to understand the difference between codecs and file formats and what combinations of codecs and formats are legal. I was surprised the first time I found out that PCM should be little-endian in WAV, big-endian in AIFF.

+12
source

You can probably do this with the right set of Core Audio blocks, but it will probably use a lot of CPU. You should convert the data ahead of time (perhaps during build?) If you can.

0
source

All Articles