We’re extremely close to submitting our first title “Tilt to Live“. We plan on submitting it this upcoming Friday. After a long and grueling (but awesome fun!) development cycle we’ve learned a ton. I figured an interesting way to distill our new found knowledge it would be in very short “dev tips” for developing an iPhone game. Today I start out with audio:
Compressing Audio
By the end of development our game weighed in at 16 MB. We wanted to go below the 10MB limit so users could download our game over-the-air. Quickest solution? Compress the audio. Now, we were already using some compression but we have over 60 audio files! The main crux of the problem is we want to be able to quickly compress all our audio to a certain format, build it, look at final build size, and test for quality. For this I wrote a quick script:
#!/bin/bash
rm -rf caff
mkdir caff
for i in _.wav
do
afconvert -f caff -d ima4@22000 -c 1 $i caff/${i%%._}.caf
done
Now for a little explanation on my setup:
- I have a single folder (let’s call it ‘finalAudio’) with all the original, uncompressed wave files used in our game.
- The script sits inside this ‘finalAudio’ folder as well and I run ‘chmod +x build_audio’ where ‘build_audio’ is the name of my script so I can just click on it in Finder when I’m wanting to re-export my audio.
What the script does:
- It removes any folder/file named ‘caff’ in the current directory
- it makes a new directory inside ‘finalAudio’ called ‘caff’. This is where the compressed audio will go
- It looks through all wav files inside ‘finalAudio’ and runs the ‘afconvert’ utility on each file and puts the resulting compressed file in ‘caff'.
I’m not going to go into the details of all the options you have with afconvert and what audio formats the iPhone supports. There’s plenty of documentation online covering that already.
Just an interesting sidenote: we took our 13-16MB game and shrunk it to 6.5 MB using ima4@22000 with 1 channel.