Audio Settings SetDSPBufferSize Causes audio to stop completely

Hi !

I’m making a simple piano app for android that can play midi files, so far everything is going well except that i have a minor latency issue for playing audio samples.

I tried to set DSPBufferSize to Best Latency in the project settings , it gave me a lot better latency on my android galaxy nexus (buffer length is 256 with Best Latency chosen) , but still , 256 seems not enough for a music app, so i tried to set DSPBufferSize to even a lower value with a script:

function Awake () {
AudioSettings.SetDSPBufferSize(256, 4);
print (“LowLatency”);

}

on pc, it worked perfectly , i was able to go as far as 200 of buffer length, but on mobile, as soon as i run the script, audio stops completely , i tried all bufferlenght values (1024 , 512 , 256 , 200 , 128 ) but all of them destroys the audio until i restart the app (the app keeps running fine but without audio)
…any help would be appreciated
Thanks in advance

anyone?

anyone that knows how to do it will get his name in the credits in the app when its released plus a link to his profile/website

Cm’on guys it can’t be that hard!

Old thread, but since many people have sound delay issues on android, here is what i have found out (no solution unfortunately)

I have an HTC One S and a Nexus 7 (1st gen).
The HTC has horrible sound delays no matter what i try regarding buffer and audio formats. I could use no other buffer size than 256, so i guess its device specific. The Nexus 7 has no delays what so ever, so i just decided to stick with the default best latency setting. It has some touch input latency though, but the sounds fit the visuals perfectly - i think this is important to distinguish between touch → sound and gameevent → sound.
I realize this makes it impossible to guarantee any kind of user experience regarding sound, as it differs too much from device to device. Its a shame.

Yes it is…i ended up buying ipad 4 , porting the project to ios and forgetting about android until unity fixes their engine …iOS has incredibly low latency support with unity.

When you set the dsp buffer size all audio stops. Simply grab all the audio sources that were playing and run Play on them again.

Unfortunately its not a Unity issue. If it was they could fix it.

It’s an Android issue (the audio lag, not the total non-functioning), which they addressed in a more recent Update, badly. It turns out that their “Low latency” trickery API stuff only works on specific devices, most of which are made by google themselves; the rest unable to benefit at this time.

I believe most devs who have dealt with this issue have done so using FMOD Ex. It also appears to be a closely guarded trade secret, as it certainly separates the wheat from the chaff.

1 Like