tags:

views:

661

answers:

5

I have some music that loops. The .wav file size is about 8 meg. I load this and just loop it... everything was working fine until I added another 4 meg .wav file. Now the game crashes... removing the additional audio file fixed the crashing.

So how can I reduce the size of these .wav files? I thought about releasing the memory after I'm done with the 4 meg file but what I tried didn't work (and I'd rather the game itself be a smaller file size so it's easier to download).

Thanks!

+3  A: 

Wav in a uncompressed format will inevitably take up tons of space. 8 Megs is not really big for an uncompressed wav.

You should consider an alternate, compressed format such as mp3 or aac. You might need to link in a decoding library though.

Check out this link on including mp3 files in your iphone app:

futureelite7
+2  A: 

If your WAV files are stereo, you could try making them mono. This would basically half the file size. The disadvantage would obviously be that your sound is now mono.

TandemAdam
+5  A: 

If you're only playing one sound file at a time, just use mp3 or aac. That way you also get hardware decoding, for improved performance and battery life.

Unfortunately, the iPhone can only play one hardware decoded sound file at a time. So if you're looking to ever play more than one at once, you'll need to do your own decoding of the second file; IMA 4:1 is recommended, though you'll have to find or implement your own decoder, Apple doesn't give you one.

This is all based off of this blog post, which goes into a bit more detail.

C Pirate
+1  A: 

I wouldn't use WAV. Take a look at ffmpegx. It's free, runs on the mac and will convert your waves files to MP3 or a host of other formats.

OhioDude
+6  A: 

Actually .WAV is a container. The contents can be compressed or uncompressed, it all depends on the WAVEFORMATEX structure contained in the first "fmt " tag in the .WAV file.

For instance, in Windows 7 all of the built-in sounds are .WAV files that contain MP3 data.

You can just author your .WAV files as MP3 files and (assuming that the iPhone correctly handles the .WAV container) they should work.

Larry Osterman