Quick Sign In:  

Forum: General Discussion

Topic: Script - Converting beats to seconds
I'm trying to script a button that displays the time remaining until the next cue. The button is named 'query', and if I use 'cue_countdown' as the action, it shows a live countdown to the next cue - but in beats. How can I convert this to seconds and fractions of a second?

I'd like the button to display 18.5, for example, if we're 18 and a half seconds away from the next cue.

I've tried playing with the param commands, but I can't figure out the correct calculation, or if this is even the right route to take. Any help much appreciated!
 

Posted Thu 14 Dec 23 @ 11:36 am
AdionPRO InfinityCTOMember since 2006
cue_countdown currently returns a number. To tell VirtualDJ it is measured in beats, you can use param_cast 'beats'.
After that, you can use param_cast 'ms' to convert it to milliseconds.
From there you could use param_multiply 0.001 to convert it to seocnds
cue_countdown & param_cast 'beats' & param_cast 'ms' & param_multiply 0.001
 

Posted Thu 14 Dec 23 @ 11:47 am
locoDogPRO InfinityModeratorMember since 2013
There I go with the primitives again, not as neat as Adion's but shows the underlying math.
param_multiply 'cue_countdown' 'get_bpm & param_1_x' & param_multiply 60 & param_cast '0.0'

countdown num * (1/bpm) * 60, the cast just sets it to 1 decimal place
 

Posted Thu 14 Dec 23 @ 11:56 am