MrDatabase
MrDatabase

Reputation: 44455

How can I reduce the size of .wav audio files for iPhone apps?

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!

Upvotes: 3

Views: 2999

Answers (5)

Larry Osterman
Larry Osterman

Reputation: 16142

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.

Upvotes: 7

OhioDude
OhioDude

Reputation: 1070

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.

Upvotes: 1

C Pirate
C Pirate

Reputation: 444

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.

Upvotes: 7

Adam Harte
Adam Harte

Reputation: 10510

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.

Upvotes: 2

futureelite7
futureelite7

Reputation: 11502

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:

Upvotes: 3

Related Questions