• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Timing of UI events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Timing of UI events


  • Subject: Timing of UI events
  • From: Andrew Coad <email@hidden>
  • Date: Mon, 13 Sep 2010 11:56:51 -0400
  • Importance: Normal

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@hidden)

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:

This email sent to email@hidden

  • Prev by Date: INSTALL_PATH ignored in XCode
  • Next by Date: Re: Question about architecture
  • Previous by thread: Re: INSTALL_PATH ignored in XCode
  • Next by thread: Re: Timing of UI events
  • Index(es):
    • Date
    • Thread