views:

91

answers:

3

I want to know if it is faster to load and play a small wav than a small mp3 file on android media player. The wavs are about 30 KB and the same files as mp3s are about 20 kb. The mp3s have the advantage to save resource space. The sound files have to be played with split second timing.

A: 

I have no technical "stuff" to back me up here, but since no one else has taken a crack at this, I will.

I know that mp3s have "better" compression than wavs, thus the file is smaller. This would imply, however, that it would take more cpu to "uncompress" the files. (This may be done on dedicated hardware so it could be a moot point.) Additionally, since the files will be inflated, it may be deceiving to see the mp3 file's smaller size and think it would be quicker to load and play.

Considering the wav file format's history, and that it serves as a 'lowest common denominator' when it comes to exchanging sound files between different programs (per Wikipedia), I would make an educated guess that it would be faster to load and play a small wav file. This is very dependent on Android's software implementation of audio libraries as well as the hardware so if anyone knows more, it would be great to hear their take.

Guzba
Looks like Soundpool will fix my current problem of sounds close together not being precise. But I also would like to hear from them on this. I am sure that the smaller file size is good since it is a raw resourse, but there is some decompression time. Thank you.
Tim Wayne
+1  A: 

Hi,

For such small sounds, you will get best results with SoundPool.

ognian
yep, this is what I need. I should have added that the sounds seem to wait for the other to finish, then load and play. I thought it was working to load a new raw sound and then would play it late. That may be correct but Soundpool seems to have the sounds loaded already and can overlap if needed. I used the help at http://www.droidnova.com/creating-sound-effects-in-android-part-2,695.html to get my code running. Thanks
Tim Wayne
A: 

Even the weakest android devices have ample computing power to play an mp3, and probably have hardware acceleration for it as well. The real question is the setup overhead for playing a wav vs. playing an mp3, which should be fairly easy to measure programmatically.

I'm a little surprised you're getting such a poor compression ratio with mp3. Even lossless compression algorithms tend to get a 2:1 compression ratio with wav. Given that an android device probably isn't hooked up to audiophile-quality speakers, you should be able to get away with 64 kbit/s mono mp3 compression, or even lower. If you can get the file size under 4K, it'll fit in a single memory page, which is about as low as you can get for OS overhead.

If for whatever reason you're stuck with a 1.5:1 compression ratio, it's probably not worth the extra work.

Chris
I use Goldwave to compress wavs to mp3s and usually get a much smaller file but these files are very short time wise(less than a second sometimes) so maybe that is why the files are only a little bit smaller.
Tim Wayne