dooglehead:
A quick glance at your code tells me you are inaccurate at computing the beats.
first: be sure the program uses 60 FPS. If you don't change the TargetElapsedTime to 60 FPS a Zune game will automatically use 30 FPS! 60 FPS is a lot more accurate as you can guess...
Next thing is this:
Code:
timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
if (timer > interval)
{
tick.Play();
timer = 0f;
blinking = true;
}
- You use Milliseconds to measure time. Milliseconds seem quite fine for us, but TotalTimeFromSeconds is a double value which is more accurate.
- if the current timeframe exceeds the interval, you just set the timer to 0. I think this causes your inaccurateness. 30 FPS is about 33 milliseconds. If you are 1 millisecond in front of the next beat you will be 32 ms behind it the next frame. Then you just cut off 32 ms from your timescale and throw it away. 32 is a lot when you need to be accurate. So instead of setting timer to 0 you should subtract the interval from the timer like:
Code:
if (timer > interval)
{
tick.Play();
timer -= interval;
blinking = true;
}
I did not look through every line of your code but this is the code for timing and thats the things I found when looking at it.
Another problem I have with my own Metronome is, that if you play a sound it will not start in that exact milisecond. Sometimes it needs some ms to actually be played. This causes some inaccurateness of the tones, too. But we can't do anything about it.
The more important it is to stay in rythm with time or it all will sum up.
Hope that helps!