pouët.net

Go to bottom

4klang syncing and latency

category: code [glöplog]
 
So, I'm working on a new 4k, and we'll be using 4klang for music. To sync, I need to get the current time into the music.

I've used waveGetOutPosition() so far, but noticed that there's some latency that it doesn't seem to take into account, and which varies depending on the load my computer is under (lower resolution => lower latency, higher resolution => higher latency).

So, how are you people syncing to 4klang? Maybe using the env/note buffers would help, but I really need the current time, and not events.
added on the 2013-03-22 12:32:52 by cmr cmr
Isn't it just latency on your rendering pipeline - like the command buffer holding several frames...
You'll probably need something to synchronize the renderer (which takes space..)
added on the 2013-03-22 13:07:17 by Psycho Psycho
Hmm perhaps, but I don't really have much latency I have introduced myself. If so, the latency should be in the OpenGL driver or something, I just render a frame, wglSwapLayerBuffers(), then render the next one. But yeah, I guess I could correct for the latency incurred by rendering 1 frame.
added on the 2013-03-22 13:13:17 by cmr cmr
Maybe stuff like glFlush() and/or wglSwapInterval(0) would help.
added on the 2013-03-22 13:15:50 by cmr cmr
There's a limit to how many frames the GPU can render in advance. Might not be just 1...
added on the 2013-03-22 13:16:02 by raer raer
Thanks guys, I now have perfect sync with glFinish() and adding two times the frame time to the current time (to try to account for double buffering, which I still do want)! And glFinish doesn't seem to have affected performance.
added on the 2013-03-22 14:03:56 by cmr cmr
glFinish is a quite drastic solution - forcing a synchronization by reading out a result of the previous render would be better.
Can't quite remember, but doesn't opengl have a simple single-call method for reading out a (few) pixel from the backbuffer - then do that right after the swap. (thus waiting for the result of the previous frame, not the one just presented). And then still offset by frametimes.
added on the 2013-03-22 16:48:33 by Psycho Psycho
Yeah, glReadPixels. That could work. I could benchmark a bit and see if it's faster than glFinish. Using glReadPixels would likely use more bytes, however, as it needs some arguments.
added on the 2013-03-22 17:10:46 by cmr cmr
However, I didn't see any visible drop in fps when using glFinish. But I didn't do any measurements.
added on the 2013-03-22 17:15:00 by cmr cmr
Afair glReadPixels might or might not block execution. it depends if it needs to swizzle BGRA to RGBA or something...
added on the 2013-03-22 17:29:37 by raer raer
Will try it on Sunday.
added on the 2013-03-22 17:32:56 by cmr cmr
glFinish() before every wglSwapLayerBuffers() actually doesn't seem to carry any performance penalty in my case (and I have the same GPU as the compo hw). I'll keep it as is for the party version.
added on the 2013-03-23 23:16:38 by cmr cmr

login

Go to top