Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I recently purchased some short (approx 3 min) background music tracks. I have the tracks in three formats: AIFF, MP3 and WAV. How can I compress these files such that the quality remains intact (for the most part) and the file size is relatively small?

I'm especially interested in the "before" and "after" file formats. So far I've tried compressing the MP3 format to m4a. This reduced the file size substantially... however the quality was significantly degraded.

I'm definitely open to reducing the tracks to much shorter (approx 20 sec) loops. Also note these background music tracks will be used on the iPhone (need to support back to the 3G). I have access to Logic Express 9 and Garage Band... and I'm open to trying Audacity or other software.


Edit: I'd like the file size to be around 300 Kb. This way it loads quickly on the 3G.

MP3 is a compressed format. For best quality you should choose a lossless (AIFF, WAV) format as the starting point of your conversions. –  bummzack Aug 17 '10 at 6:22
How small do you want them to be? –  BRaffle Aug 17 '10 at 9:51
Don't worry about loading the entire file at once. You're probably better off streaming the file as long as you aren't doing a lot of other I/O. The Cocoa APIs support that directly, I think. –  BRaffle Aug 17 '10 at 12:48

4 Answers 4

up vote 3 down vote accepted

The iPhone has hardware decode support for MP3 and AAC (M4A), so you'll want to use one of those formats. In other words, if you play an MP3 or M4A on the device, it will use very little CPU. OGG used way too much CPU the last time I tried it. In my experience, AAC will compress better in general. But it depends a bit on what frequencies are present in the source audio. Unfortunately you'll probably need to just try a few settings until it sounds ok. You can import your wav files in iTunes and right-click to convert them to AAC. Try some of the built-in quality options and see of the files end up small enough. Then, if necessary, start tweaking things like bitrate and quality. A variable bitrate will result in a smaller file usually but it can be difficult to determine how much it will compress.

EDIT: When I was trying to play OGGs on the iPhone, it was via FMOD and it was a 1st gen device. So, things might have changed since then. Still, unless the rest of your app isn't really doing anything CPU intensive, you might as well not spend CPU cycles decoding audio if you don't have to since MP3 and AAC are essentially free.

EDIT2: Also, to clarify the whole M4A/AAC thing, M4A is an mpeg container file that can contain AAC-compressed audio. AAC is the official successor to MP3. According to wikipedia, a 1MB/minute AAC stream (by 128kbps constant rate compression) will give you hi-fi transparency (i.e. nobody can tell the difference between compressed and the original). I'm not sure how accurate that is, but it sounds about right.

EDIT3: Your quality degredataion going to M4A was due to starting with an MP3. Always start with an uncompressed format, like WAV. I believe AIFF is normally uncompressed, but I'm not sure if that's always true.

EDIT4: The AAC compresser that's in Logic 9 might do a better job than the one built into iTunes, but the process will probably be more complicated.

Starting w/ WAV and going to m4a seems to do the trick. Thanks! –  MrDatabase Aug 17 '10 at 13:28
You have to be careful about relying on the hardware audio decompression. It can only decompress one at a time. If you don't do things like prevent background music from playing you can get in a situation where the OS decides to decode it in software which might have negative performance impacts. –  Tetrad Aug 17 '10 at 17:17
Regarding OGG, it's still considered too CPU-heavy for use in resource-starved environments like mobile. FMOD's Designer tool dropped support to export soundbanks in OGG Vorbis format, and now instead uses the new CELT codec. –  michael.bartnett Apr 30 '11 at 13:39

While this is of dubious value with your actual situation, the best way to make small background music is to use a MOD-style format. These are formats that contain a small number of sound samples and the music in a note-by-note format, rather than a gigantic waveform that's been compressed to squeeze space out.

Check out the S3M and XM formats, as well as the original venerable MOD format.

Sadly, there's no practical way to convert MP3 into MOD besides paying someone to do it by hand, and even then you may lose music effects as you're limited by the technical abilities of the format and the player.

i suggest to have a look on modarchive.org. They even have a java jmod player so you can tune in to each title. –  mhaller Aug 17 '10 at 15:54

You can reduce the bitrate; this is most likely what you did (without knowing) when you moved to m4a. This has a direct effect on filesize but does quickly fall off in quality. The bitrate is the number of bits per second that the music plays; as you can imagine, if you allow it a higher bitrate or a higher number of bits per second, it will use those bits to represent more detail in the music and so the music will sound better. It's perhaps synonymous to "resolution" of an image (but if you kept the image the same physical size).

You might also try the ogg (Ogg Vorbis) format, it's an open format that is supposed to compress pretty well, certainly better than mp3 but I don't know how it compares to m4a.

Finally, you can try switching the tracks to mono; this will halve their size. You can then perhaps use an algorithm to dynamically "spread" it back out to stereo in realtime. Typically, however, this makes it sound pretty terrible. Try it and see what you think.

In any case, don't use WAV or AIFF files; they store raw, uncompressed audio waves. You absolutely want to go with a compressed format such as mp3, m4a, wma (yuck) or ogg.

I believe the iPhone can decode MP3 and AAC much faster than other formats like Vorbis, leaving you with more CPU time budgeted for important things. So even though the compression ratio is about the same, Vorbis has a major disadvantage. –  user744 Aug 17 '10 at 10:38

WAV to MP3 should give you about 11:1 compression. I think Ogg Vorbis is pretty much the same. The difference in quality should not be noticable by the human ear. This compression ratio is pretty good. At a decent quality, 20-second loops won't come out over 1MB (I think). There's plenty of open source software that can get your files from raw to ogg.


I am extending my answer by recommending you compress the raw audio to Ogg format. This can be done really easily with open source tools or you can write your own converter with the Vorbis encoding library (it's free!). Streaming Ogg files with OpenAL should be perfectly viable on the iPhone.

I subscribe to the OpenAL mailing list there've been quite a few questions relating to OpenAL on the iPhone lately.

The general approximate rule of thumb for compressed music is one meg per minute. On mp3, that comes out at slightly below standard quality. On ogg, that comes out at slightly above standard quality. Note that this is stereo, and mono should reduce in size somewhat further (no, not a factor of two, the compression algorithms are smarter than that.) –  ZorbaTHut Aug 17 '10 at 6:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.