Can I ask for advice on the most accurate way of determining the exact time
that a UI event occurs at? I have timing information coming into the
application from the audio sub-system - this is translating audio samples into
host time. I need to compare the time that the user touches a UIButton relative
to the audio events. There is approximately a +/- 2-5mS window either side of
the audio event within which the application considers the two events to be "at
the same time."
Right now, in early protoyping, I am grabbing the host time in the UIButton
event handler thus:
- (IBAction)handleButtonEvent:(id)sender {
UInt64 hostTime;
uint64_t hostTimeInNanos;
hostTime = mach_absolute_time();
hostTimeInNanos = hostTime * hostTimeToNanosConversionFactor;
if (![sender isKindOfClass:[UIButton class]])
return;
switch ([sender tag]) {
case kETRTRightPadButton:
// handle right pad touch etc. etc
// compare hostTimeInNanos to audio timestamp and figure difference
I am assuming that this is not the best way as I am grabbing the time after the
event has been dispatched which could add indeterminate delays and certainly
more than the 2-5mS window I'm trying to measure within.
I can see that UIEvent has a timestamp of type NSInterval which has
sub-millisecond resolution. Should I use this? What is the relationship between
this timestamp and mach_absolute_time()? Any better ways to do this?
Andrew Coad
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]