I'm trying to calculate an alogirthm based on elapsed time to calculate score based on a music beat. I have the music beat divided into 4 because that's the time measure of that beat. So If the user presses the correct key at the third beat, which is of course when the perfect beat would be, I'd like it to obtain the best score. I've tried doing this:
score=percent(bpmt.elapsed,bpm/3);
int scoref(int int1,int int2) {
return int1*100/int2;
}
bpmt.elapsed
being how much time was elapsed between the start of that beat and the time that the user pressed the key and bpm being the total number of milliseconds of that particular beat.
Can anyone tell me a better way to do this please? I think it requires more advanced math and it's kind of beyond me.