- Home /
iOS - Audio Lag?
Hello,
I have an audio file thats played through my AudioSource every time the user taps on the screen. I've noticed that there is a slight lag between me touching the screen, and the audio playing, about 0.2 second of a lag. It doesn't seem like much, but when you're playing the game - it can be very off putting.
What I've done:
Made sure the audio actually starts playing at the very start of my audio clip
Made it into a WAV (I read they're better for iOS)
Decompress the audio on load
Made it a 2D audio (its supposed to be 2D anyway)
Yet there is still a delay, why is this? Its only a small file (144KB) Thanks
This probably isn't worth mentioning, but it does catch people out... does the actual audio file have any empty space at the top? Or does the sound start exactly at the beginning of the file?
Thanks for the response, I did mention that I did that. But no - that isn't the issue unfortunately. Still working around.
Answer by MakeCodeNow · Feb 15, 2014 at 06:41 PM
There's a bit of lag inherent to the touch event and your framerate, but I bet the problem is that want a smaller Audio DSP Buffer. Bigger buffers will stutter less, but have higher latency. Try something smaller for you. Once you do that, you can probably even use compressed audio and be fine.
Okay - so how would one apply a smaller buffer, do I literally just do 'AudioSettings.SetDSPBufferSize()' in my code somewhere? What would be the recommended 'bufferLength' and 'numBuffers'?
Thanks
Yeah, you just call SetDSPBufferSize. What I would reccommend is that you star with the default values returned by GetDSPBufferSize, and then chop them down until you get something that works. Just be sure to test on a range of devices!
Under project settings > audio, you can also change the buffer size within that by default. That seemed to do the trick. Thanks :)
Your answer
Follow this Question
Related Questions
Rhythm game input latency issue 0 Answers
Android audio lag solutions 1 Answer
!RIDICULOUS! Audio Latency - Android 3 Answers
Audio Lag Between Multiple Listeners 0 Answers