Time Remaining display

Discuss Lemur and share techniques.
Post Reply
jdjd
Newbie
Posts:10
Joined:02 May 2013 21:05
Time Remaining display

Post by jdjd » 29 Dec 2013 17:36

Hello!
hoping some of the more math-headed can help me out here...
I have a "time remaininng" osc feed coming into Lemur from VDMX that sends (in seconds) the amount of time remaining til the end of a clip. (328.23 for example)

I want to display this in a HH:MM:SS format... Multiple monitor patch displays would be supah fine if needed. (1 for hours /1 for minutes/etc.)

So far by using NumFX on the VDMX side I can get stuff like 12.23 minutes or 767 seconds remaining, but am hoping to get it into that wonderful "human readable" format like 0 hours 8 minutes 32 seconds... or 00:08:32

My math and scripting simply ain't up to it... Help me Spock...


thanks!
jd

oldgearguy
Regular
Posts:315
Joined:02 Nov 2013 11:19

Re: Time Remaining display

Post by oldgearguy » 30 Dec 2013 11:37

// 60 seconds = 1 minute; 60 minutes = 1 hr, 3600 seconds = 1 hr.

hrs = floor (remaining / 3600);
mins = floor ((remaining - (hrs * 3600)) / 60);
secs = floor(remaining - (hrs * 3600) - (mins * 60));

so if you had 3822 seconds remaining --

floor (3822 / 3600) = 1
floor ((3822 - (1 * 3600)) / 60) = floor (222 / 60) = 3
floor (3822 - (1 * 3600) - (3 * 60)) = floor(3822 - 3600 - 180) = 42

That's just a quick and dirty approach, there's probably a more efficient way to do all the intermediate calculations.

You can also have fun with the Modulo operator (3822 % 60) = 42 for possibly a faster (maybe less clear) way to get seconds remaining.

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Time Remaining display

Post by Softcore » 30 Dec 2013 19:14

Yup modulo comes in handy!

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Time Remaining display

Post by Softcore » 30 Dec 2013 19:46

here's an example - the "remaining" time is the constant expression "rem".....
Attachments
timer.jzml
(3.82KiB)Downloaded 81 times

jdjd
Newbie
Posts:10
Joined:02 May 2013 21:05

Re: Time Remaining display

Post by jdjd » 30 Dec 2013 21:29

Genius. Thanks!!

Thanks for the module softcore, I had juusstt gotten things working using oldgearguy's approach.... That helped "get my learn on" better, i will dissect yours next. Keeps me from being lazy and just "using the widget"

this forum rocks!
thanks much mucho!
jd

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Time Remaining display

Post by Softcore » 30 Dec 2013 22:23

Its the same logic anyways! I just presented it in "Lemur" format! ;)

Post Reply