# $ksp_timer vs. $engine_uptime



## Hans Adamson (Mar 12, 2014)

I just noticed this:

_"The KSP timer is based on the CPU clock and thus runs at a constant rate, regardless of whether or not Kontakt is being used in real-time. As such, it should be used to test the efficiency of script and not to make musical calculations – for musical calculations use the $ENGINE_UPTIME timer."_

Does this mean that if Kontakt runs as a plug-in, it is possible to render a mix off-line when using $ENGINE_UPTIME, but if using $KSP_TIMER - off-line rendering is not possible?

And what about $DURATION_BAR and $DURATION_QUARTER? Can they only be used for on-line mixing and not for a quick off-line rendering of a mix? They are both in microseconds, and the reference manual says $DURATION_BAR can only be used if the clock is running.

Thanks,
/Hans


----------



## mk282 (Mar 13, 2014)

$DURATION_BAR will only work (if the clock is not running) in the plugin version, otherwise it will return 0 in standalone.

$DURATION_ constants can be used in off-line renders as well, no problem there. They have no relation to $KSP_TIMER nor $ENGINE_UPTIME.


----------



## andreasOL (Mar 13, 2014)

Right.

See my posting at

http://www.vi-control.net/forum/viewtop ... t=#3777721

For computations regarding where are we in a musical context ENGINE_UPTIME - especially in an off-line situation - and the DURATION variables (if present as Mario pointed out) can be used.

But not KSP_TIMER!!!

Andreas


----------



## Hans Adamson (Mar 13, 2014)

Thanks guys.

I wonder why there can't be a microsecond timer for off-line bouncing, when the DURATION variables (which are measured in microseconds) can be used off-line? If their durations can be measured accurately off-line, why couldn't any lapsed time be recorded with the same accuracy?...

/Hans


----------



## Dynamitec (Mar 15, 2014)

One of the problems with a microseconds timer would be, that it's automatically reseted every 30 minutes because there would be a overflow. Kontakt can't handle such large values. That could lead to problems. Btw. same goes for ticks_to_ms($NI_SONG_POSITION). Be careful if you play something at about 30 minutes in your sequencer.


----------



## gwhiz (Feb 22, 2016)

andreasOL said:


> Right.
> 
> See my posting at
> 
> ...



Hi Andreas, this link is broken, is there another way to find your post? Thank you! Just to be clear, DURATION_ only works when I've loaded my instrument into my DAW and am playing or recording?


----------



## szcz (Feb 26, 2016)

gwhiz said:


> DURATION_ only works when I've loaded my instrument into my DAW and am playing or recording?



That's $DURATION_BAR, it only works when transport is running in DAW (while playing or recording).
$DURATION_QUARTER, $DURATION_EIGHTH etc. will always work. So, you can calculate bar duration using $SIGNATURE_NUM and $SIGNATURE_DENOM.


----------



## andreasOL (Mar 22, 2016)

gwhiz said:


> Hi Andreas, this link is broken, is there another way to find your post? Thank you! Just to be clear, DURATION_ only works when I've loaded my instrument into my DAW and am playing or recording?



Hello...just saw your reply. The post I was referring to is at

http://vi-control.net/community/posts/3777721/

best,
Andreas


----------

