How bad is Android SoundPool? What is the alternative to using?

I saw Android SoundPool as a mechanism for implementing sound effects in my shared game development library. It seemed perfect.

But a little research shows that all kinds of errors are in SoundPool . Are SoundPool errors current?

As I develop the library, any errors in SoundPool become errors in my library, and I want to isolate my users from this.

So my question is basically: which API should I use for audio?

Using AudioTrack and recording my own mixer is out of the question. But, obviously, it would be preferable to avoid this. And is there any API for decoding for me?

I need to be able to play a reasonable amount of simultaneous sound effects (at least 16, say), and even more open ones. Sounds should start with low latency. WAV files must be supported (MP3 / Ogg no matter). Sound effects should support a seamless loop and dynamic individual volume control. The life cycle of an Android application must be properly maintained.

I heard that there is a 1 MB limit for SoundPool , this is probably acceptable for every single sound effect, but not for all buffers / sounds. Can someone tell me what the limit is?

Finally, I need to be able to play background music, in compressed formats, with low CPU usage. I guess MediaPlayer perfect for this. Can it be used in parallel with another API?

I know that a few people used MediaPlayer to populate SoundPool . But does it support the features that I need?

Are there any other audio APIs that I missed?

+73
android audio soundpool
Jun 26 2018-11-11T00:
source share
3 answers

Just add some recent feedback on this issue. I have been using SoundPool for some time in an application with a fairly large database for key click sounds. Our use case:

  • Must play immediately
  • Sound up to 3+ in parallel
  • We use setRate across the entire range [0.5f-2.0f]

Now I am faced with two serious problems associated with the device, and decided to reduce my losses and disconnect from SoundPool

  • A large number of 4.4 LG devices (mainly the LG G2 / G3 line) had their own failure with their SoundPool implementation. This was fixed in the update (eventually), but we still have many users with unimproved devices.
  • Sony Xperia devices currently have all kinds of problems with SoundPool as reported by other users . In my case, I found that if you use setRate with rate > 1.0f , SoundPool with launch throws exceptions until your application closes (and starts a bunch of batteries in the process).

TL; DR; I no longer think it's worth the dangers / nervousness of SoundPool debugging

+15
Jan 27 '15 at 19:59
source share

Stick to OGG files and SoundPool will be fine. It is the nature of the multi-platform beast that is Android, that there will be hardware configurations that will not work with any important program, no matter how hard the programmers try.

If this is a large and well-funded project, add one of the main phones for testing to financing. This is actually much cheaper than the time it takes a programmer to research and try to guess what their performance is.

Unfortunately. This does not seem to be the answer you were looking for. Good luck

+8
Jun 28 '11 at 16:17
source share

DISCLAIMER: I have little experience with MediaPlayer, and I do not know any successful experience with other APIs that I mention, and the following information is based on what I read in the DOC and what I read from the search queries Google

You can use mediaplayer (for background music) with other audio APIs, since MediaPlayer automatically starts its own stream, but I believe that it has a high CPU load, and I donโ€™t think it will require compressed bits very well, but I donโ€™t sure.

There's also JetPlayer http://developer.android.com/reference/android/media/JetPlayer.html , which seems to work a lot for efficient use, but it will work very well with playing background music and then playing other sounds on as needed in the game. From what I read about the DOC, a MIDI file is required (I think?), And you turn off the sound and turn on the tracks to make it work the way you want.

I like AudioTrack because it gives you the ability to edit sounds at runtime by changing the frequencies of the sound, and SoundPool can do the same.

Although for your situation, AudioTrack does not look like it will work well, because it will take two streams to play two sounds, because AudioTrack blocks (I'm sure).

And with SoundPool, I think that since you have 16 sounds, maybe in each thread there can be two threads with one SoundPool and apply 8 sounds for each SoundPool. I really don't know, though, since I haven't even tried to use SoundPool.

And again, my information is not based on experience, but on what I see from what I read, so I can be completely or maybe just wrong, or, hell, who knows.

And I don't know anything about SoundPool errors since I did not investigate it.

+3
Aug 18 '11 at 23:16
source share



All Articles