# SOS to those who have programmed music games

**URL:** <https://forum.kirupa.com/t/sos-to-those-who-have-programmed-music-games/305199>\
**Category:** programming\
**Created:** [February 21, 2010, 5:30am UTC](https://forum.kirupa.com/t/sos-to-those-who-have-programmed-music-games/305199 "2010-02-21T05:30:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JiaLiLabyrinth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@JiaLiLabyrinth](https://forum.kirupa.com/u/JiaLiLabyrinth)\
**Post date:** [February 21, 2010, 5:30am UTC](https://forum.kirupa.com/t/sos-to-those-who-have-programmed-music-games/305199/1 "2010-02-21T05:30:47Z")

</div>

I have been working on a music rhythm game, and it seems that there is always a lag between the keyboard input and the beat map data. And now I don’t even know where to start solving the problem.

Here’s the thing:  
My game pretty much imitates Rhythm Heaven’s call-and-response gameplay, so the player (response) has to repeat a rhythm pattern played by another character (call).  
I have 3 BeatSequence objects, each storing an array of timing data, one that indicates the user’s correct timing, one that indicates when the call takes action, and another one that triggers in-game cut scene for narrative purpose.

The whole game runs on a main loop that runs every 20 milliseconds (this is maintained by the Timer class.) As the mp3 files is played on a SoundChannel object, the main loop will check on SoundChannel.position and compare it with the data in the 3 BeatSquence objects. I also kept 3 index values to keep track of the beat data that should be checked from these 3 BeatSquence objects.

People have been complaining about a lag between when they push the key and when the player character reacts. I tried placing some fuzz value to make sure there’s a good amount of tolerance for error, but now I’m not sure if that’s even the problem now.

[FONT=&quot]Anyhow, I’m just wondering what sort of schematic design other creators of music game in Flash might have used. What can be the bottleneck here? Before I start posting giant codes up here, I will like to hear from fellow creators of Flash music games what frequent bottlenecks and rules of thumbs are out other.

More of my game can be found [here](http://a.parsons.edu/%7Ewui669/DivineBeats/?p=250).  
[/FONT]
