Friday, March 19, 2010

Improving music performance in the iPhone SDK

For people who like to copy and paste other people’s solutions without researching the problem in depth, this entry is for you (since I don’t go into depth).

I was noticing my iPhone game framerate being really jerky when playing music that I encoded using IMA4 format, so I changed it to LEI8.  The file format is somewhat big, being lossless, but the tradeoff is that I hardly notice any jerkiness now.

In short, I was previously running this to convert my files before:

/usr/bin/afconvert -f caff -d ima4 Source.mp3 Target.caf

and now I’m doing this

/usr/bin/afconvert -f caff -d LEI8 Source.mp3 Target.caf

I don’t notice any sound quality degradation either.  I also tried LEI16 but it wasn’t worth the doubled size for no noticeable quality gain (Your Mileage May Vary).