Need exact timings

AeroForce 64
01-25-2008, 06:28 PM
Hello everyone, I am developing a application to read subtitles and the function to read subtitles is ready but I have a problem...
It reads .srt subtitles, which format is for ex.: "00:01:58,393",
well, I have a label with the timing in this format, but sometimes it skips some dialogues..

I think this is because the timing is not exact, for example, the dialogue is in "00:01:58,393", but the timing skips from "00:01:58,390 to "00:01:58,400", i am using the timeGettime api and a timer control (interval 1) to show it on the label with the timings.

I am almost sure that the problem is in the timer control, but what can i use instead of it? because i want to show the timing of the api timegettime in a label in real time.

How can i solve this?

**Hope you understood, english is not my native language.


Thanks

jaxbot
01-25-2008, 06:54 PM
I "understood" fine :)

I believe the problem is that your CPU might be too slow, or your hard drive.
Well, my computer can't ping it's hard drive every 2 milliseconds.

-Jaxbot

OnErr0r
01-25-2008, 07:23 PM
timeGetTime granularity is ~10 ms on Win2K+. You can get much finer timings using QueryPerformanceCounter called in a loop. Alternatively, consider a multimedia timer (timeSetEvent), which can time down to 1 millisecond.

http://www.xtremevbtalk.com/showthread.php?t=96917

AeroForce 64
01-25-2008, 08:04 PM
Thank both of you.. well, i get it, but can you give an example of how to show the time in miliseconds in a label? please some code..

thanks

Rockoon
01-25-2008, 08:47 PM
timeGetTime() has a configurable granularity, in milliseconds, using timeBeginPeriod() and timeEndPeriod()

timeGetTime() ticks at a rate of the smallest requested granularity of any app on the system. By default it is 10ms, 15ms, or 55ms depending on the OS.

QueryPerformanceCounter() has much better resolution, but there are some serious problems with this function on multicore CPU's that have not been patched (such as appearing to run backwards)

timeGetTime() can reliably give you an accuracy of +/- 0.0005 seconds, which is good enough for most purposes, and also gives a real value of time convertable to the current system clock.

I had started a thread with a link to some research on the topic of accurate timing on PC's:

http://www.xtremevbtalk.com/showthread.php?t=285797&highlight=accurate+timing

AeroForce 64
01-26-2008, 05:29 AM
Thank you for the info, but OnErr0r please give me an example of showing the time in miliseconds on a label using timeSetEvent api, I am just a begginer in Visual Basic, the thread that you gave me is too difficult and english is doesnt even my native lenguage.. please just an example...

Thanks

And if anyone is interested, i found a post where someone analizes the accuracy of different api. Check it here: Timer test results! Timer control, timer function, gettickcount, querryperformance, etc. (http://www.vbforums.com/showthread.php?t=18440)

OnErr0r
01-26-2008, 11:19 AM
Since you are new to VB I would suggest you avoid timeSetEvent. QueryPerformanceCounter should work for you, but look at the article linked by Rockoon and this article (http://msdn2.microsoft.com/en-us/library/bb173458(VS.85).aspx) to handle potential multicore CPU problems.

You'll find the declares and even a class wrapper which I posted if you do a forum search.

Cerian Knight
01-26-2008, 11:49 AM
QueryPerformanceCounter is my recommendation, as well. For good accuracy on some chipsets, Microsoft recommends using it together with GetTickCount: http://support.microsoft.com/kb/274323

The thread on vbforums is misleading, as the accuracy and precision of different APIs can vary significantly depending on CPU, chipset, operating system, processor driver and CPU load.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum