sound effect using SoundPool

by djp » Fri, 13 Feb 2009 10:32:33 GMT


Sponsored Links
 Hi,

there seems to be a dead-lock problem when using sound effects with
SoundPool. I was hoping the the problem would be fixed in the new
firmware update, but unfortunately, it was not. The application still
locks up after couple of minutes when playing sound effects using
SoundPool. My application is a game playing a background music
scenario with multiple simultaneous sound effects.

Any word from devs as when we can expect stable SoundPool would be
very welcome.

Best
David

--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Robert Green » Fri, 13 Feb 2009 13:02:09 GMT


 David,

Please search and read about all my soundpool tests.  Basically you
must use OGGs totalling under 1MB and you can't call the stop or pause
methods.  Many of us use it but you must be careful.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


sound effect using SoundPool

by Stoyan Damov » Fri, 13 Feb 2009 16:05:09 GMT


 Listen to Robert's advice, and most importantly, if you don't have a
need to manipulate the sounds during the game (e.g. Robert changes the
pitch dynamically in his game) stay away from the SoundPool.
Simply build your own sound pool based on MediaPlayer instances - I
know it works. It probably consumes more resources but you can't trade
safety for resource consumption. Also, there's a remote possibility
that in a OTA update the SoundPool might disappear and/or be replaced
by an incompatible class, which will break your game.

Cheers,
Stoyan





--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Peter Sankauskas » Fri, 13 Feb 2009 16:27:55 GMT


 Has anyone been kind enough to create a sound/media pool using
MediaPlayer instances and made it open source for the rest of us to
use? It seems like it is a pretty common problem that many developers
could take advantage of some well written and tested code.

Peter






--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Stoyan Damov » Fri, 13 Feb 2009 16:36:33 GMT


 I think I might be able to decouple the pool from my game and get rid
of some entropy which sneaked in over the months, and then I don't
mind posting it here. Only it's Friday 13th and I don't release on
this date :P Seriously though my daughter turned 1 today, so I don't
think I'll work in the evening/tonight. Maybe the weekend.

Cheers







--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Markus Junginger » Fri, 13 Feb 2009 17:14:49 GMT


 


How does Robert implement pitching? Is there a recommended lib?
A nice sound fx lib?

Thanks!
--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Stoyan Damov » Fri, 13 Feb 2009 17:23:20 GMT


 You need to ask Robert for the details, but I think SoundPool.play's
method has an argument controlling pitch (I don't remember which if
the 3rd to 5th argument that was).





--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by djp » Fri, 13 Feb 2009 19:35:12 GMT


 Thanks for information.

I'm already using OGG files totaling about 200kB. The original
uncompressed WAV files are 1.4MB. I'll try to further reduce number of
files and the total size. Also, I'm not using stop/pause as it crashes
the application instantly :)

Robert, are you saying that your application is working fine with
SoundPool? If so, could you please post information about files sizes,
format, frequency, channels, and bitrate?

I'm not sure if the MediaPlayer approach is suitable for me, as the
latency is the high priority here. I would rather go without sound
effects than with laggy sound effects.

Still, it would be nice to see an "official" word about SoundPool.
It's a very important feature, especially for game developers.




--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by tasos.klei...@gmail.com » Fri, 13 Feb 2009 21:29:13 GMT


 I have written a class that utilises MediaPlayer and SoundPool
objects. MediaPlayer is used to play looping music and SoundPool is
used for sound effects. Have a look at my blog
 http://tkcodesharing.blogspot.com/2009/02/class-for-playing-music-and-sound.html 
--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Sundog » Fri, 13 Feb 2009 23:26:38 GMT


 Wow! Thanks very much!



On Feb 13, 6:29am, "tasos.klei...@gmail.com"


--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Marco Nelissen » Sat, 14 Feb 2009 00:34:35 GMT


 There is a known problem (fixed in cupcake) with SoundPool that will cause
it to lock up if you try to play more simultaneous sounds than the capacity
of the SoundPool. If you specify the capacity of the SoundPool to be higher
than the largest number of sounds you will ever play at the same time, then
it should work.






--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Robert Green » Sat, 14 Feb 2009 01:46:48 GMT


 One more thing you need to know:

Soundpool crashes if you change the pitch over 1.5 or under .5.  I
created multiple "engine" samples for higher and higher pitches, so no
matter how high you hear the engine on light racer, it never goes
above 1.5 playback rate.  Soundpool is actually a really nice API for
game sound FX and I really hope it doesn't go away because it's
perfect for that application.  I just hope that things like that are
fixed in the future.




--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by djp » Sat, 14 Feb 2009 04:19:51 GMT


 Increasing the capacity of the SoundPool solved the problem. Thank
you!




--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Sundog » Sun, 15 Feb 2009 06:00:31 GMT


 I am using your class and setting it up as you indicate, but having
the same difficulty I did last time I tried to use SoundPool; I have
seven one-shot sounds that trigger from buttons and in the emulator it
works every time, but on the phone itself, occasionally all 7 work but
usually only a random few do or sometimes none at all. Any idea what
might be going wrong?

On Feb 13, 6:29am, "tasos.klei...@gmail.com"


--~--~---------~--~----~------------~-------~--~----~



sound effect using SoundPool

by Dave Sparks » Sun, 15 Feb 2009 07:11:26 GMT


 There are a lot of fixes to SoundPool coming in the Cupcake release.

I need to check on the crash you mentioned - I don't recall seeing
that before and it should give you an error, not crash. The range is
dependent on the ratio of the sample rate of the source and the
hardware output.





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How to use android's built in zoom controls for View or ImageView

I can use the built in zoom controls for WebView or MapView. But don't
know how to access the control for View or ImageView. If the control
is not implemented, can we access the bitmaps for the zoom control
supporting WebView or MapView. Thanks in advanced!

-John

--~--~---------~--~----~------------~-------~--~----~

2. Copybit implementation. function strecth and blit

Hello all,

I am trying to implement Copybit .  I find that surface flinger is using
copybit->strecth  funcion everywhere to do the blitting.

Where is the copybit->blit function used ?

Can copybit be implemented partially. Like It can use 2D dma to do the
blitting but cannot support the resizing ?

Any inputs would be appreciated.

Thanks in advance,
-- 
with regards vishal

--~--~---------~--~----~------------~-------~--~----~

3. How do I export 'sent mail' from default email client?

4. SlideME Marketplace for Windows Mobile

5. Cannot get Log.isLoggable working as documented

6. Traceview OutOfMemory error

7. cerrno equivalent in android