No announcement yet.

Getting time elapsed since preset was loaded?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting time elapsed since preset was loaded?

    Hi everyone I am new to preset development so this may be a basic or obvious question but I would really like some help here as I haven't found the answer I'm looking for in the preset authoring guide.

    I know you can use the time and frame values to get the time and number of frames elapsed since the program started. But how would you go about getting the time or frames elapsed since the preset was opened? Is there a work around for this? I don't necessarily need the exact time, just a value that starts at 0 on preset initialize, and counts up over time.

    I'm not sure how active this forum is anymore, but hopefully someone out there can point me in the right direction.

    Thanks for your time.

  • #2
    Hi mickmos
    That is easy: The preset initialisation section is executed once only, when the preset is started, while the per frame section is run each frame.

    So set a variable in the initalisation section such as
    t0 = time;

    In the per frame section, time-t0 then gives you the running time. Similar with frames.

    To display the value of any variable, use monitor in the per frame section:
    monitor = time-t0;

    You may also be interested in a very little known intrinsic variable named "progress". It starts with zero at preset start, and counts up; when it reaches one, the next preset will be loaded. I never used it, but it gives you the possibility to do something - maybe fade out - as the preset reaches its end.
    That means that milkdrop knows the preset running time in advance. This time can be adjusted in the options.

    Note - while editing a preset, you should disable the automatic preset change by activating numlock on the keyboard (if there IS a numlock key). The effect is that milkdrop will not change the preset while you are writing it. It does so by setting the preset running time to infinity: hence with numlock on, "progress" will always be indicated zero. That caught me a while ago, and made me think that this progress variable is buggy; it is not.

    EDIT: It's the scroll lock button, not numlock.


    • #3
      Hey Nitorami thanks so much for the reply, this is exactly what I needed and you explained it all so well. Thanks for helping me with my first roadblock and hopefully have set me down a good road of making something cool with Milkdrop.