New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Music stutter #18
Comments
Interestingly I don't experience this problem in either BJ8 or KQ2, but in The Apprentice. At least in the Windows version, not on Android though. This is the only game I ever had this specific sound issue. |
I'll test this more some time later. Might be there are more conditions for this to happen. |
A long due update: this seem to be related to threaded audio feature. Occurs not all times and not in all games, but when threaded audio is off this never happened. May or may not be related to #82. |
Tried it in Virtualbox with Windows 8. Sound always stutters in this particular way with threaded audio enabled. Bummer. Also checked out monkey's build but it didn't make a difference for me. E: I also tried my branch with the updated libraries. Unfortunately this doesn't help with the issue either. |
Just noticed: The stuttering stops if the polling loop runs more often. Changing https://github.com/adventuregamestudio/ags/blob/master/Engine/main/engine.cpp#L1275 to 20 ms completely cures the problem for me on Win 8. In the non-threaded version the polling loop runs multiple times per frame, I would assume that it runs less often even with 10 ms delay. But that would have to be measured. I was initially just choosing a value that "works" while not wasting cycles. |
I do not know how the audio poll works in detail, but is there a way to calculate delay by knowing minimal size of data chunk buffered at a time? |
This comment was marked as abuse.
This comment was marked as abuse.
The engine request 16/32 kiB buffers for static/streaming ogg and mp3. This is enough for 100/200 ms of audio data at 44.1 kHz in 16Bit stereo. But the problem is that the Sleep() call in the Windows platform driver is split into 5 ms chunks. It seems like the standard timer resolution of Windows is 15 ms, which therefore causes 3 times the requested delay. That's why it stutters. Running Windows Media Player in the background brings the resolution down to about 8 ms, I remember reading something about that effect too. For some reason Windows switches to a 1 ms timer resolution when you start an AGS game on my Windows 7. It does not do this on Windows 8. |
Putting timeBeginPeriod (http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624%28v=vs.85%29.aspx) with 1 ms into the startup code fixes the issue for me. Since we do something to that effect anyway (it just doesn't work on Windows 8) we might as well go this route. Other apps do it too, e.g. Firefox also sets 1 ms. This is a program that can show the current value of the timer: http://www.lucashale.com/timer-resolution/ |
I pushed a possible fix here: ade47ce |
According to game devs' replies the stuttering is gone. There's still a minor problem with Pamela lip-sync, but that is probably different issue. |
I noticed that music stutter sometimes. Can't tell what kind of music format is that.
This happened in Ben Jordan 8 and King's Quest 2 so far (but I just did not test much games).
Does not happen when I run original game's executable (and it's quite distinctive).
It's like AGS repeats a small bit of music every 3-4 seconds.
The text was updated successfully, but these errors were encountered: