I am working on a simple metronome on the iPhone. What the application is doing right now is to start the timer by entering the timer function every 1 / 1000th of a second. Then it checks the current time and application launch time (I use the function CACurrentMediaTime()).
CFTimeInterval currentTime = CACurrentMediaTime();
if (self.beatingStartTime == 0) {
self.beatingStartTime = currentTime;
}
if ( (currentTime - self.beatingStartTime) >= self.timeIntevalBetweenTicks * self.internalTimerCounter ) {
self.internalTimerCounter ++;
}
If there is a good time to play sound, code that uses OpenAL to play it starts.
Mainly. I checked the sounds that play when I run both in the simulator and on two devices (iPad and jailbroken iPhone 3GS), and there is a problem - when I recorded the sound and looked at the waveform in Reaper, some sounds play too late, and some of them too early (even I could understand the “too late” part, I really don’t understand how it is possible to play earlier, then it should - since the application checks the number of seconds each time, it basically cannot be an euler, and then the specified time, but this, according to my recommendations).
At the same time, there are some metronome applications that are known as “rock solid” when it comes to time, so I think there is a way. I'm just wondering what I'm missing ...
. 1/1000 , , 1/100th .
edit 2: ( ), . , , , , - , , .
3%, 10-15 , . - , ? iPhone-, iPad-, , - - CACurrentMediaTime() . ?