Is there a way to reduce the sound buffer size?

Turns out, this it quite a big issue in our case.

When we move the player between tiles, it takes 0.12 seconds. We want to play a sound when you start moving, but it seems like the sound buffer is too big. We’re getting considerable lag, which seems to be around 0.1 seconds.
This means that the user can see the animation, almost from start to end, before the sound actually starts.

Is there any way for us to reduce the sound buffer size?

On what platform are you running? I doubt this is a sound buffer problem.

I only tested on my Windows 8 PC, but I can try it on my android device as well. I’ll get back to you in a bit

Looks like it’s even worse on device, tried it on Dell Venue 8.

This time the animation has time to finish completely before the very first sound is heard :frowning:
I’m guessing the audio delay is around 0.14 on device and 0.1 on the PC

Here’s a video: https://drive.google.com/file/d/0B6HpAiSNy9eDTTNWTnBvTTRtRDg/view?usp=sharing

Ok, I’ve never experienced any sound lag on Mac or iOS but we need to look at this. Can we run some tests on your project after the weekend?

Absolutely. I just tried it on my Macbook and didn’t notice any sound lag

I did the following test.

  1. Replace the character move sound with the sound used on the start screen GUI (stone_large).
  2. Commented out play() in the main GUI and tested the responsiveness of sound on the start screen only.
  3. Put back play(), started the game and tested the responsiveness of sound when the character moves.

There is a clear difference in when the sound plays in these two cases. There is even a difference in responsiveness when moving the character and pressing the “back to menu” GUI element at the top of the screen.

Is it possible that you have some logic running that causes this character move sound lag?

(EDIT: I should also add that we have indeed seen sound lag issues present on certain Android devices. This seems to be a problem with the OS on those devices)

Hm, possibly, not sure what that would be though, apart from a loop in update for each target that checks whether or not they’re covered.

The issue remains the same in the main menu for simple buttons too though, but it might be less apparent.

This might help a bit?

Does .ogg vs .wav matter in this case? Currently using .ogg

I didn’t test the main menu, I tested the start screen with only one big button.

Yeah, that’s the one I tested as well

Ok. I compared with other apps on my mac and did not notice any lag at all on the start screen. In game, however, there’s noticable lag, but only on the board - not on the GUI elements. Check that you don’t have some state that is changing over a frame or two.

Recorded using an external mic with my headphones at the mouse on Windows 8, looked at the final waveform to measure delays, rounded to nearest 100:th of a second:

Lag between mouse release and character movement sound:
0.23s
0.21s
0.20s
0.18s

Lag in menu between mouse release and click sound:
0.15s
0.20s
0.19s
0.21s

Not sure if it’s useful, but, there’s some stats in case you need it :smile:
Again, not having this issue on my Macbook, this is only on Android and Windows.

I’ll look into some performance fixes to see if it helps, but it looks pretty consistent to me

Ok. Still, it’s not consistent on mac.

I can verify that we’re getting lots of lag when doing some internal tests on Windows 8.

Windows 7 seems fine though. Filing a bug.

1 Like

Just for the record, I just recently started testing my game on a Galaxy S7, and have bad lag on the audio as well; when testing within the Defold editor, sounds occur exactly when they should (e.g., a spaceship runs into an enemy ship and the explosion sound occurs immediately). On the device, there is about a half-second delay. I went back and looked at games I’ve built with other game frameworks, and there seems to be a tiny bit of a delay on the device, but it is virtually unnoticeable…

Thanks!
Bryan

Hmm, interesting. Would it be possible to isolate this behaviour to a small Defold project and share it with us so we can take a look? I haven’t heard of any complaints from the game teams here at King about audio delays.

I discussed this with @ChristianM last Thursday. The problem is noticeable on BBS canvas as well. “Fixing” sound is quite a big issue, but making the buffer size customizable and separating buffers for music and transient sound should improve the experience for developers quite a bit. There’s currently no decision to actually do this, and no issue in JIRA, but something that is worth mentioning.