Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Dan Ray said, <code>NSTimer</code> and <code>NSThread</code> are not reliable for precise timing. If I were you, I would use an <a href="http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/Introduction/Introduction.html" rel="nofollow">audio queue</a> - it will request buffers of audio through an input callback, and you will fill them. Provided you respond promptly, it will request and reproduce these buffers at <strong>exactly</strong> the hardware sample rate, so you can do some simple calculations to figure out the timing of your taps and fill each buffer from your file or from samples stored in an array or vector. You'd fill it using <code>AudioFileReadPackets</code> if you choose to go straight from your file.</p> <p>This will be a little more work but it's much more versatile and powerful. You can use audio queues for live synthesis and processing of audio, so their timing is perfectly precise as long as you meet their deadlines. If you're careful about processor usage, you could have a tap sound every few milliseconds with no issue.</p> <p>Take a look at the <a href="http://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html" rel="nofollow">SpeakHere</a> sample application to get started with audio queues. <a href="http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/Introduction/Introduction.html" rel="nofollow">Audio units</a> are also useful for this sort of thing, and you can provide data to them through a callback, but they take a little more setup and have a steeper learning curve.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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