Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You probably don't want to check something as fast as possible, since that would lead to performance issues.</p> <p>If you want something that updates with the display, you could use <a href="http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html" rel="nofollow">CADisplayLink</a>. You can google around for examples, like this <a href="http://zearfoss.wordpress.com/2011/03/09/drawing-with-cadisplaylink/" rel="nofollow">one</a>.</p> <p>If you don't need to link it to display refresh, you can set up an <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html" rel="nofollow">NSTimer</a>, or use a variant of <a href="http://developer.apple.com/library/Mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelector%3awithObject%3aafterDelay%3ainModes%3a" rel="nofollow">performSelector:withObject:afterDelay</a>.</p> <p>If you need high resolution timers, look at <a href="http://developer.apple.com/library/ios/#technotes/tn2169/_index.html" rel="nofollow">this technical note</a>.</p> <p>NSTimer and performSelector both have a resolution around 50-100 ms, which is not sufficient for sound playback.</p> <p>I would recommend you use a separate real time thread with mach_wait_until() as explained in the tech note. Using the code from <strong>Listing 2</strong> in the technote, something playing a sound every <code>BEATS_PER_SEC</code> using <code>play_beat()</code>, would look like this:</p> <pre><code>void play_beat_thread(int argc, const char * argv[]) { mach_timebase_info(&amp;timebase_info); uint64_t time_to_wait = nanos_to_abs(10ULL * BEATS_PER_SEC); uint64_t next = mach_absolute_time(); while (true) { next = next + time_to_wait; mach_wait_until(next); play_beat(); } } </code></pre> <p>If you want more advice on high resolution audio timing, I suggest you reframe this question along the lines <em>"How do I manually schedule high resolution audio playback on iOS/OS X"</em>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload