AutoHotkey Community

It is currently May 27th, 2012, 12:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: January 3rd, 2009, 8:38 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Chris wrote:
For some reason on my PC, it doesn't seem to sleep at all (or inconsistently) if the frequency is below 40 or so
Maybe with ultrasound frequencies it works? My speakers buzz even at 32000Hz, though.

What did you see with DllCall("Sleep"..., w/o timeBeginPeriod and timeEndPeriod dll calls? If it turns out to work consistently, no need to change the Sleep command, we can just use DllCall("Sleep"... for short delays. Maybe it works in my case only because some other programs already set the time period to 1ms. Do you know how to tell?

I think a more precise timer is more important than a short Sleep. I tried the obsolete Winmm\timeSetEvent dll call. It works in XP and Vista, but I had mysterious crashes. Maybe someone knows the recommended CreateTimerQueueTimer method?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2009, 9:30 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Laszlo wrote:
What did you see with DllCall("Sleep"..., w/o timeBeginPeriod and timeEndPeriod dll calls? If it turns out to work consistently, no need to change the Sleep command, we can just use DllCall("Sleep"... for short delays.
Without timeBeginPeriod, Sleep(1) sleeps for 15.62 ms on this Windows XP PC, which uses the ACPI multiprocessor HAL as shown in device manager.

Laszlo wrote:
Maybe it works in my case only because some other programs already set the time period to 1ms. Do you know how to tell?
Perhaps when you exit all scripts that may have called timeBeginPeriod, the OS automatically restores the normal period (even if timeEndPeriod wasn't called). If not, perhaps you could test after a fresh reboot to see if Vista's Sleep() is in fact capable of shorter durations than XP's. Some BIOS setup screens mention the fact that Vista has some kind of new support for high resolution timing.

Laszlo wrote:
I think a more precise timer is more important than a short Sleep. I tried the obsolete Winmm\timeSetEvent dll call. It works in XP and Vista, but I had mysterious crashes. Maybe someone knows the recommended CreateTimerQueueTimer method?
If timeBeginPeriod were used as the mechanism, it seems much harder to implement finer resolution in SetTimer than in Sleep because the message-processing system would have to be altered at a low level. Therefore, it would probably be better to use CreateTimerQueueTimer() or something else that generates callbacks, interrupts, or messages at very short intervals. I don't know much about this area.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group