This content has been marked as final. Show 4 replies
I think I have a different calculator than you, but for me, the
maxInteger comes out to just under 25 days... not hours.
put the maxInteger
All of which is neither here nor there. You can try to make the
milliseconds a float, but I doubt that would help. I don't know what
Director would do if the milliseconds goes beyond that. Often when a
number that should be an integer goes beyond the maxInteger, it turns
into -2147483647 (negative maxinteger) and stays that way. I have never
had trouble using the milliseconds, and I have used it on some long term
kiosks that stayed up for as long as Windows would stay up without
crashing. If you are having trouble with it, you may want to make your
calculations based on a variable that is set by a timer or timeout
object so it can be reset if it gets too high.
-- the issue ---
Assuming you are on windows (should be the same on mac, but not so familiar
with mac internals) the milliseconds returns the result of the windows API
This function returns an unsigned long (32 bit) value. The range of such a
value is 0-4294967295 (4GB). So, after about 49 days, this value will reset
to 0, and continue from there.
Furthermore, when converting the value to a signed long -as director is
doing- you get a negative value after half that time (25 days, not hours).
You can convert the negative value to a positive float by using:
if (val < 0) then val=float(the maxinteger)*2+2 + val
put the maxinteger
put float(the maxinteger)*2+2 + ( the maxinteger +1 )
put float(the maxinteger)*2+2 + (-1)
You can also workaround the timer reset issue, by comparing the last value
to a previous one.. However:
-- solution --
I had created a small Xtra a while ago, that returned high precission
(sub-milliseconds accuracy) time as a float number.
I believe this should solve your problem. So, if you are on windows, mail me
to send it to you. info at (reverse >) gr. rtr.
> but when the time is negative, is the system counting up (toward 0), or
> down (increasingly negative)?
increasingly negative up to -1, 0, 1, 2...
"Applied CD" <email@example.com> wrote in message
> I?ve got a giant array of audio sample data (glFreqData[sampleTime]),
> 1700 samples, 16 frequency bins per sample. I?m using the following code
> convert system time to a sample time index however on some machines I?m
> a negative sample index. My guess is that _system.milliseconds is
> maxInteger but I don?t see any documentation on what to expect when that
> happens (if you do the math, _system.milliseconds will exceed maxInt in
> under 25 hours). I can easily flip the sign but when the time is negative,
> the system counting up (toward 0), or down (increasingly negative)?
> mySample = ((_system.milliseconds/100) mod glFreqData.count) + 1
Mike Blaustein wrote:
> Often when a
> number that should be an integer goes beyond the maxInteger, it turns
> into -2147483647 (negative maxinteger)...
put the maxinteger+1
> ...and stays that way.
OP: there's a technote on the issue:
Thanks all. That tech note should really be part of the documentation. Sorry about the math, yeah it’s 25 days, not hours. For my own purposes I only need to count out regular beats at 1/10 second intervals until my data set runs out, then start over.
The following should work for me. I know there’s a chance of repeated beats transitioning from – to + and again at + to – however this small glitch occurs at the millisecond level, far below the resolution of my data set. Also, I know the abs() shouldn’t be necessary but mySample is used as a list index so now I’m being paranoid and want to be sure it’s never negative.