-
Apr 10th, 2017, 10:30 AM
#1
Thread Starter
Hyperactive Member
Hi resolution timer
Hello Group,
I know this has been discussed and I have searched, but I have come up with nothing relevant..
I have a multi threaded activeX exe and need my main timer to be triggred more accuratly. I am currently using "setTimer" api call. 80% of the time my timer is on time, but 20% it can get off.
I was wondering if anyone has found an elegant/easy bu accurate way to make sure the timer calls are as exact as possible.
I found the solutions using the multimedia timer.. but my concern is I have to distribute a .tlb file with it ( and have very little knowledge about what this is) also this solution seems to require a user control which does not seem to be able to work in my multi threaded activeX exe project.
any suggestions?
-
Apr 10th, 2017, 10:47 AM
#2
Re: Hi resolution timer
Axisdj
Could you elaborate on the nature of "it can get off" .. ie, by how much?
Also, it might help if you post a code snippet to show where the "it can get off" occurs.
EDIT
I take it that you are using the Interval property, ie ..
Code:
Timer1.Interval = 1000 ' milliseconds, ie, 1 second
.. and setting it to some "appropriate" smaller value.
Spoo
Last edited by Spooman; Apr 10th, 2017 at 10:55 AM.
-
Apr 10th, 2017, 10:57 AM
#3
Re: Hi resolution timer
You'll also have to define "exact as possible". After all, one would presume that all the system timers are exact as possible within the limitations imposed on them. Windows is going to be inherently inexact with timers because there are higher level interrupts that can throw off very precise timing. The OS could bump your thread right off the CPU for longer than your timer interval. It may not be likely to happen, but the more precision you want, the more likely that a preemptive multi-tasking OS will foil your plans. I've heard of people using dedicated hardware timers for higher precision stuff, such as some oscilloscopes, and the like. It all comes down to how precise you need to be, and what your tolerances are.
My usual boring signature: Nothing
-
Apr 10th, 2017, 11:06 AM
#4
Thread Starter
Hyperactive Member
Re: Hi resolution timer
So...
The timer is set to 50ms using setTimer api call...
Most of the time the time elapsed between calls is .0625, but every second the time eleapsed between calls goes to .203.. .056... then back to .0625
The timer updates the user interface etc... but the call that needs the accuracy pulls audio data through an audio engine.
I tried separating the timer call to another timer, but with the same results.
I guess something in the main thread where the timer is calling back is getting stalled. I will look deeper to see if the stall is in my program or windows not calling on time.
-
Apr 10th, 2017, 11:53 AM
#5
Re: Hi resolution timer
High resolution timer: http://www.vbaccelerator.com/home/VB...r/article.html
The link to the download goes to an empty file, but you can download it from here.
-
Apr 10th, 2017, 02:00 PM
#6
Thread Starter
Hyperactive Member
Re: Hi resolution timer
Originally Posted by Eduardo-
Thank you...
I would like to try it.. but would like to fully understand it. Can someone enlighten me on the tlb / odl file stuff.
Thanks!
-
Apr 10th, 2017, 06:45 PM
#7
Re: Hi resolution timer
Couple notes:
Don't worry about a tlb. You don't redistribute it, it gets compiled into your app. Consider the odl file as source code
One of the reasons a standard timer could be failing you is that timer events are about the lowest priority messages; they can be delayed getting to your routines.
-
Apr 10th, 2017, 10:32 PM
#8
Thread Starter
Hyperactive Member
Re: Hi resolution timer
thank you LaVolpe for the concise answer.. I feel much better about using this timer and will do so...
-
Apr 11th, 2017, 08:24 AM
#9
Lively Member
Re: Hi resolution timer
Originally Posted by axisdj
thank you LaVolpe for the concise answer.. I feel much better about using this timer and will do so...
.... I had good experiences with the freeware RSTimer OCX. Very easy to use.
more infos see: http://www.vbforums.com/showthread.p...-Timer-2-1-0-1
I don't find a download location for now, if you can't find it, I could mail it to you.
I use it for a MIDI/OSC Sequencer/Beatmachine. Still some jitter, but I think just the unavoidable one, due to VB6 is only single threading.
btw. LaVolpe if you are reading this, may be you could have a look at:
http://www.vbforums.com/showthread.p...onality-broken
Any hints or comments would be highly apprecciated!!!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|