sound delayed on my android device.

i am making mobile game which kill monster by touching.
so I write codes for making a sound when it touched.
but the sound delayed a little bit about 200~ 500ms. it is less then 1sec.
some people have same problem like me.

i already changed setting of DSP buffer size in AudioManager. but it doesn’t work.

is there solution for it?

sorry, hunz. my plugin is customized for my app. and also i think it would be little bit hard to make it general. but making the plugin is not so hard. if you can write few line of code, i think you can make it work.
anyway, my solution is using SoundPool.

following code is from my android plugin. if you know some programmer. it will be very helpful to make your plugin.

for making android plugin, you need to read it.

and my code.

private void initSound()
{
sound_pool = new SoundPool( 20, AudioManager.STREAM_MUSIC, 0 );

	soundNumbers[0] = sound_pool.load( this.getApplicationContext(), R.raw.bhammer, 1 ); 	
	soundNumbers[1] = sound_pool.load( this.getApplicationContext(), R.raw.bhole, 1 ); 
...
public int playSound(int i,boolean isForever){

	return sound_pool.play( soundNumbers*, 1f, 1f, 0, isForever? -1:0, 1f );*
  • }*

  • public void stopSound(int i){*

  •   sound_pool.stop(i);	*
    
  • }*

  • protected void onCreate (Bundle savedInstanceState)*

  • {*

  •   super.onCreate(savedInstanceState);*
    
  •   initSound();*
    


if you don’t know any programmer, you can send me email for that. (my email is ‘ulgerang@gmail.com’)

I’ve written an asset that uses the native Android audio system for low-latency playback.

Check it out. :slight_smile:

Asset Store: Android Native Audio