|
Post by Roger Cabo on Jan 10, 2020 2:13:40 GMT 1
Hi everyone,
I like to call a function for a midi music tool at about 200 times per second. Does any one know how to do this without pooling on a timer?
The following example cooks the CPU. This is not good!
Dim t = 0; Do DoEvents CallMe() Loop
Proc CallMe if (oTimer - t <= (1000/200)) return; endif t = oTimer .... Do anything EndProc
In c# it's easy.
private static void SetTimer() { // Create a timer with a two second interval. var aTimer = new System.Timers.Timer(1); // Hook up the Elapsed event for the timer. aTimer.Elapsed += OnTimedEvent; aTimer.AutoReset = true; aTimer.Enabled = true; }
private static void OnTimedEvent(System.Object source, ElapsedEventArgs e) { // this function is called 1/ms }
But I have no idea how to call System.Timers out of GB32.. Does anyone know how this can be solved in GFABASIC32?
Thanks and kind regards, Roger
|
|
webu
Full Member
Posts: 148
|
Post by webu on Jan 14, 2020 12:40:09 GMT 1
Ocx Timer tmr tmr.Interval = 5
|
|
|
Post by Roger Cabo on Feb 8, 2020 2:25:53 GMT 1
Thank you very much! And sorry for the late reply.
* Seems the demo works for the version 2.57 ony. ($ManifestOff option)
1) Would you so kind and explain the values ?
.res = 1 ' milliseconds .frs = 300 ' frames .fps = 500 ' frames per second
2) Can I set up a more precise ms timing as well with frs and fps? Dim bpm# = 128.0 Dim resolution# = 384.0
Eg. Resolution = (60.0sec / bpm# / resolution) * 1000) = 1.220703125ms
That would be absolutely great.
|
|