- Home /
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.
http://answers.unity3d.com/questions/60096/android-audio-delayed.html
i already changed setting of DSP buffer size in AudioManager. but it doesn't work.
is there solution for it?
I found there is a slight decrease in latency if you do the following;
Change Buffer size (which you've done)
Audio Format : Compressed ($$anonymous$$PEG)
3D Sound : un-select
Load Type : Decompress on load
Create a SFX Pool
I'm working on a rhythm game and I've had to approach it differently so that it works and feels in time. I hear it works fine on iOS
thanks for answers. my Unity version is 4.1.2f1 . for that problem, i made android plugin which have functions that make sounds. and it works.
anyway, thanks for your anwsers.
Oh sweet. I'm no coder. I use play maker to do all my logic and am stuck with whatever flaws exists in those frame works. If you ever felt like sharing/selling the plug please P$$anonymous$$ me.
Simple plugin and Unity project are available here: https://github.com/fadden/android-audio-bypass
Answer by ulgerang · May 03, 2013 at 01:09 AM
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. http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html
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[i], 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')
Answer by ChristopherCreates · Jun 16, 2015 at 05:45 AM
I've written an asset that uses the native Android audio system for low-latency playback.
Check it out. :)
Your answer
