I am making a music game, and when the user clicks a note, it will produce a sound. The sound, of course, should be played immediately when the user clicks, so they can determine if they were in time with the music. However, the sound seems to be lagging, especially when notes become faster.
My background .m4a music file is played using AVAudioPlayer. I decided to use this over Cocos Denshion, as I have access to the currentTime property. Maybe I'm wrong, but I don't think I can access this with CocosDenshion.
I made a wav file that is very short (less than a second). I preload the sound effect on init:
[[SimpleAudioEngine sharedEngine] preloadEffect:@"Assist.wav"];
Then, to reproduce the sound effect, in CCTouchesBegan I call:
[[SimpleAudioEngine sharedEngine] playEffect:@"Assist.wav"];
After that, he calls my code to determine points in time and points for users. Any idea why this might be lagging, or the best way to play sound effects in time with music?
EDIT: Ive tried a few things lately without any results. At first I tried to play the sounds automatically when they came to the right time in the song. There was still a lag, so I donβt think it is a touch that is slow. I also tried 3 different sound libraries.
However, when I ran in the simulator, it did not seem laggy. Does anyone have an idea? Im clueless and its main feature that I can not really bear ...