dafels wrote:noindyfikator wrote:I think it's time to fix laggy sound/stuttering
would be nice, but I don't see it happening until 2030 when AI will be in charge of the codebase
That may be the case since I encountered the sound issue only on Windows, while loftar develops on Linux.
One likely reason for this is that Windows uses 16ms scheduler time slices, while Linux-based systems usually use 1ms slices.
With this tick rate of 60Hz the audio buffer drains at a rate of ~735 samples per tick. That means if there are scheduling issues or another application takes away the CPU from the audio thread for even one tick the result can be fatal when the audio buffer is small.
The first step would be to make the default audio buffer at least 4096 on Windows.
Another thing that can improve the situation are the WinAPI functions timeBeginPeriod() and timeEndPeriod() from mmsystem.h that allow you to request a higher resolution of e.g. 1ms for your application.
There is probably some way to call them from a Java application.
And then there seems to be a separate issue that affects the audio when the client runs in the background at a reduced frame rate of 5 fps.