Is there a way I can convert an mp3 file into a wav/aiff in my iPhone app? I have an mp3 but I want to combine it with other files and the only way I know this can be done is when using PCM formats.
Can anyone help me out here?
Thanks.
Some things I tried
I tried using the AudioConverterFillComplexBuffer() method and its callback to convert the mp3 to caf but the bytes per packet and per frame are read as 0. Any ideas how I can or whether I can use this function?
Thanks again.
WAV and AIFF often (usually?) contain PCM, so what's the objection there? Or are you saying that you have to get your MP3 data to PCM in order to mix it (perhaps in a multichannel mixer audio unit). If you seriously want to do this, look at Core Audio, specifically:
Check out the ConvertFile example in the Core Audio SDK. This opens a source file for reading, describes the desired format of the target file, reads buffers from one and writes them to the other. The code exhibits 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 codec/format combinations are legal. I was surprised the first time I found out that PCM must be little-endian in a WAV, big-endian in an AIFF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With