Compensating for message latency


In the audio-loop player application I’m currently working on I’m implementing a feature that stores the current playing position when the user clicks a button, as to make a “que-point”.
To make this mechanism really tight, I subtract the buffer size from the current read position to compensate for audiocard latency. But this is not enough… after some headscratching I’ve come to the conclusion that there is a extra latency between the clicking and the handling of the message that this generates.
I’ve tried button::getMillisecondsSinceButtonDown() in the buttoncallback, but this allways yields 0.
Is there a method to get to the mouse-event responsible for the click?


Yes, buttons get triggered on the mouse-up, not the mouse down. What you could do is try overriding the button’s mouseDown callback to catch the event, and store its time (which should be pretty accurate) for use later on during the click callback.


Yes, this works great! (I also figured out the Button::setTriggeredOnMouseDown(true) method…) Many thanks!