hi there!
i would like to implement an rythm game so i learned something about the music functions and read some threads about it. unfortunatly there are not so many of them
like
http://forum.dead-code.org/index.php?topic=3269.0i see that the Get- and SetMusicPosition method doesn't work correctly so i use the Game.CurrentTime method for synchronisation like Mnemonic has suggested in some threads.
and it seems to work very exactly at the beginning but after a while it runs out of sync. to show you the problem i have following code:
first i play the loop sound:
Game.PlayMusicChannel(0,"takt.wav",true);
then i run a loop where an "X" will be written every time the music loop starts from the beginning
var len = Game.GetSoundLength(Game.GetMusicChannel(0));
var time = Game.CurrentTime;
while(true)
{
if(Game.CurrentTime-time >= len)
{
time = Game.CurrentTime;
Game.Msg("X");
}
Sleep(1);
}
i ran this script and after a few minutes the "X" won't be written exactly at the loopbeginning. it totally ran out of sync.
so first i thought the GetSoundLength() didn't work correctly but in my opinion it does. i checked the wav file in my
cubase and its the same lenght like wme says (2594 ms).
so i wonder what causes this behaviour. maybe the Sleep() method? does the CurrentTime stops when calling the Sleep()?
i know this is a very special problem or maybe i'm working in a totaly wrong direction?