Jump to content



Photo

Adlib timing behavior. (AdlibUnRegister())


  • Please log in to reply
15 replies to this topic

#1 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 23 June 2012 - 12:57 PM

Think it would be more intuitive (and usefull) if AdlibUnRegister() would completely reset things.
Ergo: This code would than actually be counting from the new AdlibRegister() timepoint. Instead of (kinda) behaving like there was no AdlibUnRegister() call at all.

AutoIt         
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Global Const $iRatio = 100 ;; 1000 Global Const $sAdlib = 'AdlibFunc' Global $iTimer = 0 $iTimer = TimerInit() AdlibRegister($sAdlib, 4 * $iRatio) Sleep((4 * 5 * $iRatio) + $iRatio) AdlibUnRegister($sAdlib) Exit #cs    result: AdlibFunc(), 409.264650422213 (+4) AdlibFunc(), 799.788431372549 (+4) AdlibFunc(), 1207.94519428939 (+4) AdlibFunc(), 1616.18206347503 (+4) AdlibFunc(), 2013.64021504222 (+4) #ce Func AdlibFunc()     DebugOut('AdlibFunc(), ' & TimerDiff($iTimer))     AdlibUnRegister($sAdlib)     sleep(3*$iRatio) ;; some simulated processing time.     AdlibRegister($sAdlib, 4 * $iRatio) EndFunc Func DebugOut($sMsg)     ConsoleWrite($sMsg & @CRLF) EndFunc


[3.3.8.1/3.3.9.4]

---

GOTO message http://www.autoitscript.com/forum/topic/141749-adlib-timing-behavior-adlibunregister/#entry997403 to skip confusing parts. (That would be message #10) (using stupid full http link, as forum post-editor is bugged to no end.)

Edited by MvGulik, 25 June 2012 - 07:15 AM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"





#2 PhoenixXL

PhoenixXL

    Be what you are, believe me its always the BEST...

  • Active Members
  • PipPipPipPipPipPip
  • 1,316 posts

Posted 23 June 2012 - 02:37 PM

Inside the Adlib Function therez no need to Unregister or ReRegister.

The script waits till the Function completes

Hope that helps
Phoenix XL

Edited by PhoenixXL, 23 June 2012 - 02:37 PM.

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. | Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. | MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead.

#3 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 23 June 2012 - 04:11 PM

Inside the Adlib Function therez no need to Unregister or ReRegister.

The script waits till the Function completes

Hope that helps
Phoenix XL

Nope, Not really helping (yet).

Why do you say "... there is no need ..." ?.. I main I know there is no need, or better in my case "no use" for it, as there is no change in the default behavior.
But that's also my point, it would be nice if there would be a use for it.

I though about the fact that I'm doing the additional adlib-registering inside the adlib call, but did not follow trough on that thought. (mainly because I think there will be no difference, or effect, by doing so. ... will test later)
Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#4 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,692 posts

Posted 23 June 2012 - 04:16 PM

What do you mean by reset? I can't see what you're trying to accomplish without a concrete example.

#5 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 23 June 2012 - 04:54 PM

If I read the OP code "as is" I think the more logical output/behavior would be something like:
AdlibFunc(), 400.~ (+4)...[*$ratio] AdlibFunc(), 1100.~ (+3+4) AdlibFunc(), 1800.~ (+3+4) AdlibFunc(), 2500.~ (+3+4) AdlibFunc(), 3200.~ (+3+4)

instead of
AdlibFunc(), 400.~ (+4) AdlibFunc(), 800.~ (+4) AdlibFunc(), 1200.~ (+4) AdlibFunc(), 1600.~ (+4) AdlibFunc(), 2000.~ (+4)

Which makes more sense to me if the code would use the names AdlibPauseCallback() and AdlibUnPauseCallback() for the adlib-register calls inside the AdlibFunc() function.

[corrections...][+codetags]

Edited by MvGulik, 23 June 2012 - 05:30 PM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#6 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,060 posts

Posted 23 June 2012 - 05:06 PM

Think it would be more intuitive (and usefull) if AdlibUnRegister() would completely reset things.
Ergo: This code would than actually be counting from the new AdlibRegister() timepoint. Instead of (kinda) behaving like there was no AdlibUnRegister() call at all.


I didn't know this was the case. In the help file it says:

Re-registering an already existing Adlib function will update it with a new time.


Have you tested that?

Edited by czardas, 23 June 2012 - 05:10 PM.


#7 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 23 June 2012 - 05:26 PM

Yep. works as expected.
But had wrong expectation. (stupid typo-bug fixed)(re-digesting result ...)
AutoIt         
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #cs    result: AdlibFunc(), 400 ... (+4) AdlibFunc(), 900 ... (+5) AdlibFunc(), 1500 ... (+6) #ce Global Const $iRatio = 100 ;; 1000 Global Const $sAdlib = 'AdlibFunc' Global $iTimer = 0, $iCounter = 4 $iTimer = TimerInit() AdlibRegister($sAdlib, 4 * $iRatio) do until $iCounter > 6 AdlibUnRegister($sAdlib) Exit Func AdlibFunc()     DebugOut('AdlibFunc(), ' & _TimerDiffRound($iTimer))     $iCounter += 1     AdlibRegister($sAdlib, $iCounter * $iRatio) EndFunc Func _TimerDiffRound($time)     Return Round(TimerDiff($time)/$iRatio)*$iRatio EndFunc Func DebugOut($sMsg)     ConsoleWrite($sMsg & @CRLF) EndFunc


[bug fixed]

Edited by MvGulik, 23 June 2012 - 08:20 PM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#8 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 23 June 2012 - 05:59 PM

Darn(2) ... back to the drawing board.
AutoIt         
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #cs    result: AdlibFunc(), 400 AdlibFunc(), 1100 AdlibFunc(), 1800 AdlibFunc(), 2500 AdlibFunc(), 3200 #ce Global Const $iRatio = 100 ;; 1000 Global Const $sAdlib = 'AdlibFunc' Global $fExit = False, $fAdlibReReg = False, $iTimer = 0 AdlibRegister('setExit', 36 * $iRatio) $iTimer = TimerInit() AdlibRegister($sAdlib, 4 * $iRatio) Do     If $fAdlibReReg Then         AdlibUnRegister($sAdlib)         AdlibRegister($sAdlib, 4 * $iRatio)         $fAdlibReReg = False     EndIf Until $fExit AdlibUnRegister($sAdlib) Exit Func AdlibFunc()     DebugOut('AdlibFunc(), ' & Round(TimerDiff($iTimer)/$iRatio)*$iRatio )     sleep(3*$iRatio) ;; some simulated processing time.     $fAdlibReReg = True EndFunc Func SetExit()     $fExit = True EndFunc Func DebugOut($sMsg)     ConsoleWrite($sMsg & @CRLF) EndFunc


---

For completion. #7 test tested outside adlib call. (no difference to result at #7) (+stupid typo-bug fix.)
Spoiler


---

On Hold: (something I don't get(yet) is bugging me ...)

Edited by MvGulik, 23 June 2012 - 09:05 PM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#9 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,060 posts

Posted 24 June 2012 - 07:24 AM

I just ran a test on this. AdLibRegister appears to reset the time as expected, so I'm not sure what this is about.

AutoIt         
AdlibRegister("MyAdlib", 2000) Dim $iTimer = TimerInit() Sleep(8100) ; 2 seconds ; 4 seconds ; 6 seconds ; 8 seconds AdlibUnRegister("MyAdlib") Sleep(1000) ; Following results should now return odd numbers AdlibRegister("MyAdlib", 2000) Sleep(8100) ; 11 seconds ; 13 seconds ; 15 seconds ; 17 seconds Func MyAdlib()     ConsoleWrite(Round(TimerDiff($iTimer)/1000) & " seconds" & @LF) EndFunc


There's a few miliseconds processing time, but the rounded results turn from even to odd (on my machine) after re-registering the adlib.

The only thing I don't get is why this function is called adlib. To me this sounds like ad libitum (ad lib) meaning free rhythm, at your leisure - ie not accurate timing - quite the opposite of the function's description.

to play the passage in free time rather than in strict or "metronomic" tempo (a practice known as rubato when not expressly indicated by the composer);


Edited by czardas, 24 June 2012 - 09:50 AM.


#10 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 25 June 2012 - 07:02 AM

Taking my time ... But your right that Adlib works as expected, when your using the adlib-reg's outside its own adlib-call scoop.
But when you use the additional AdlibRegister() commands inside its own adlib-call. It works a little differently.
The new adlib starting time-point will not be based on the moment the additional AdlibRegister() was issued. But it will be based on the start-time of the adlib-call (your currently are in).

Considering changing stuff on something, while using it, is generally not a good thing. (adlib or otherwise.) I think a general note about this in doc might not be bad thing.

Code used to check. (bug free I hope :D )
Spoiler


NTS: Recheck AdlibUnRegister(). (seems all AdlibRegister() related at this point.)

[+code comment]

Edited by MvGulik, 25 June 2012 - 07:07 AM.

Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#11 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,060 posts

Posted 25 June 2012 - 07:52 AM

I get what you're saying, but I'm not sure of the cause. I wonder if this could be related to variable scope - I think it's a reasonable assumption, but without access to the source code it will always be guesswork.

Edited by czardas, 25 June 2012 - 07:57 AM.


#12 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,060 posts

Posted 25 June 2012 - 08:49 AM

I can confirm MvGulik's findings.

AutoIt         
Global $bCorrupted = False, $iTimer = TimerInit() _TestFunc() Func _TestFunc()     AdlibRegister("MyAdlib", 2000)     For $i = 1 To 5         Sleep(2000)         ; The following line in this funtion updates start time as expected         If Not $bCorrupted Then _CorruptTiming() ; Move this line to the function MyAdlib()     Next EndFunc Func MyAdlib()     ConsoleWrite(Round(TimerDiff($iTimer)/1000) & " seconds" & @LF)     ; if you place the line here instead, AdlibRegister will not update the start time     ;If Not $bCorrupted Then _CorruptTiming() ; Allow this line to run EndFunc Func _CorruptTiming()     AdlibUnRegister("MyAdlib")     Sleep(1000)     AdlibRegister("MyAdlib", 2000)     $bCorrupted = True EndFunc

Edited by czardas, 25 June 2012 - 09:32 AM.


#13 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 25 June 2012 - 08:55 AM

The amount of time you sleep affects the adlib calls.

#14 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,060 posts

Posted 25 June 2012 - 09:10 AM

I think the tests are pretty conclusive. There's a 1000 ms disparity in my test. If the sleep and delay times are increased, the disparity appears to remain proportional to these increases, though I believe what you say - I don't get enough sleep. :D

Edited by czardas, 25 June 2012 - 09:19 AM.


#15 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 25 June 2012 - 09:29 AM

The amount of time you sleep affects the adlib calls.

Feel free to elaborate on that a bit more. Its kinda very general to me.
Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#16 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 25 June 2012 - 10:51 AM

Never mind. It's simply a bug. Here is another fun one:

AdlibRegister("MyAdlib", 9999999999999999999)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users