Game Development Community

Choosing audio formats for playback

by Blake Drolson · in iTorque 2D · 11/29/2012 (6:38 pm) · 4 replies

Hi there,

So I am porting our game over to Ipad from PC/Mac, and I understand I can not use the ogg files anymore. So I was planning on using MP3 files instead. Now I see some messages from years ago stating that the iPhone can only play one mp3 at a time. Is this true from iPad also?

Do I need to convert my background sound only to MP3 and keep the rest as wav's, or can i use all mp3's? Any other format to use that the iPad can play many samples at once for sound effects, that are smaller than wav's? Thanks for any help in advance.

#1
12/01/2012 (4:50 pm)
MP3 or AAC for music (recommendation: 64kbps 44.1kHz, less if you think it sounds good enough; check which of the two formats compresses best per tune).

IMA4 compression for effects (4:1 ratio). Go as low as you can within 16-bit. No stereo sounds, 22050 or 11025Hz, perhaps try various audio post-processing tricks if the results are really bad. If the sound is simple AND still sounds good at this point, try 8-bit for another 50% reduction. Typically 8-bit sounds like C64 laser noises will probably still be alright then :)

To convert to compressed mono with Apple's tools, do this in a terminal:
afconvert -f AIFC -d ima4 -c 1 sound.wav
No guarantees that this'll sound good on stereo samples, as it probably simply drops one channel.
#2
12/03/2012 (2:48 pm)
Hey Ronny thanks again for the good info! You are always the guy with the good answers, heh.

Hey one followup , just to be sure, is that we can only play one compressed sound (Mp3 or AAC formats) at a time? We can play as many Wav or IMA4 sound files (within reason, but more than one or two?) simultaneously on the ipad ?
#3
12/06/2012 (4:48 pm)
I'm not completely clear on the why and wherefore, but MP3 (and AAC?) are classified as "streaming media" files by Apple and don't respond well when used as effects. I don't know if there's a limit to how many you can play at once, but we're steering clear of them entirely.

WAV files are subject to the limits imposed by the engine (16 sources at a time) and may be limited by the hardware though I haven't really looked at that.

The main problem we have run into is trying to use crazy high sample rates for your WAV files - iOS just won't play them. Which is just as well, they're freaking HUGE.
#4
12/06/2012 (6:37 pm)
Yeah we looked at what we would get if we went all Wav's, and after trimming some long rain sounds and such we only went up like 5mb from ogg's, so we going to make everything wav's.

I think I read that Ios can decode one mp3 at a time in hardware, other mp3 decode would be done by the cpu so a much bigger hit on cpu load.