The first thing that strikes me: System.currentTimeMillis()
i think kind of very accurate, gives a long
value, and where as SwingTimers
request for an int
parameter; what does it say?Don't consider SwingTimers
to be accurate?
2)Suppose timing a word with SwingTimer
takes x milliseconds; if we are repeating a task (highlighting a word, like karaoke apps), i included this code:
/*see the time taken for each letter*/
int tik=(int) delay / words[index].length();
/* make adjustment(subtract few millisecs) as per the time taken by each word*/
if(tik <69)
timer.setDelay((int) (delay / words[index].length())-3);
if(tik >=69&&tik<=149)
timer.setDelay((int) (delay / words[index].length())-6);
else if(tik <=150)
timer.setDelay((int) (delay / words[index].length())-9);
else if(tik >150)
timer.setDelay((int) (delay / words[index].length())-100);
Works quiet well, but i am definitely sure i cannot rely on this,as time, length may change! How to overcome this?As change in few millisec may bring disastrous results to me.
3)At the same time i wonder which techniques dose Karaoke maker&player softwares follow???, Very accurate.