I was expected to use timeSetEvent as a timer for
my MIDI sequencer application but I've seen on MSDN site
that it's an obsolete function and I should rather use CreateTimerQueueTimer.
That's ok for me but I have few questions about it.
In my app the timer is used for synchro. An asynchronous callback function
is called every 2/3 ms and does it's job.
So my questions are:
1 - Since I need just one timer, should I create a queue for the timer
with CreateTimerQueue or should I use the default timer queue ?
2 - What flag should I use ?
(I would choose WT_EXECUTEINTIMERTHREAD but I'm not sure at all.)
3 - Timer is used only when sequencer starts playback or
recording but what do I do when it stops ?
Should I delete timer and create a new one each
time sequencer starts playback/recording ?
Or is there any way to make the timer hold
on without delete it ?
Thanks for advance
No answer at all ?
Anyway, I found out something new:
I first tried my code with the timeSetEvent multimedia timer and it seems to work fine.
Therefore I tried with the CreateTimerQueueTimer timer and I'm afraid
it's no accurate at all.
For exemple if I set a tempo at 120 bpm with a resolution of 480 tpb
the speed should be the same whatever I set the timer value to 5, 10,
15 or 20ms. But it's not the case. But may be I don't use it properly.
So now I'm not sure if I want to use CreateTimerQueueTimer instead
Is timeSetEvent still available on Windows Vista ?
Can someone tells me more about CreateTimerQueueTimer accuracy ?
My code that uses timeSetEvent function seems to be working on Vista ( havn't check that specific call but I wonder if the whole program could work as it should without these timers...)
So I suppose this function is still supported on vista even if the msdn-online specifies that only XP is supported (the msdn offline created in the 2002 specifies that all Windows versions starting with NT 3.1 and 95 are supporting this call - of course that version of msdn knows nothing about Vista)
It's common for Microsoft to say "Hey you, don't use that, use this, it's better!" when referring to many tried-and-tested functions such as the multimedia timer functions.
Of course these apparently obsolete functions would have to still work in order for applications made prior to their replacement to continue functioning.
I would suggest that you stick with what works unless you can find a reason to "upgrade".
Thanks for these answers.
I spend few hours for testing my midi ticks generator algorithm with this 2 timers.
In the tests, for each iteration all that's happening in the callback function is
written in a log file in order to compare both timers behaviour.
Well, the two log files are identical exept CreateTimerQueueTimer wich generates less itérations than timeSetEvent for the same (4000 ms) given time ?????
I just can't explain it.
Maybe the Sleep() function uses for the test is not really appropriate... I don't know.
But it seems that timeSetEvent is more regular and stable for this job.
So as you suggest: I stick with what works !
But if someone has more infos about CreateTimerQueueTimer I take them.
For those who are interested by the topic here's some useful links:
I wish I knew how the Professional sequencer's programmers (Cubase, Sonar etc....)
deal with the Windows timers. Do they build their own timers ?
PS: I've just learned that timeSetEvent was declared obsolete because it internally
calls PulseEven which is bad:
(It doesn't matter in my case because my prog doesn't use the PulseEven flag)