I am creating a rhythm-like game and have been having trouble syncing the background music with whats being drawn.
What I have been doing so far is saving the clock time immediately after starting playing the music, and then on each update I get the current clock time and compare it to the saved clock time when the music was started, giving me the time since the music was started.
This appears to be fairly accurate at the start, but as time goes by it gets slightly out of sync. EDIT: on a 9minute song it was out of sync by about 2 seconds, on a 2min song it was off by about 0.5sec. and the graphics were finishing before the music…
What I would really like is to be able to get the audio buffer position from the SimpleAudioEngine (the current sample being played), but this feature is not available and I don’t know how hard it would be to implement.
Anyone have any suggestions?