PDA

View Full Version : Is there a system variable for "now"?


mblais
02-13-2010, 09:53 PM
Is there a system variable that gives the "current time" with millisecond
resolution? Not necessarily "clock time", but just elapsed time.

I.e., so we can determine how much time passed between two
arbitrary events.

It might also be useful to be able schedule an event in the future (like Wait),
but that's just a random thought for now...

Peace,
RashaMatt

Per Boysen
02-15-2010, 09:40 AM
I don't know about such a system built into Mobius, but myself I'm using the host to indicate absolute time in order to keep track of performance time on stage. Apple Mainstage, which is my usual host, lets you set it up on screen in any font size. You may also set up your computer to display system time by the OS graphics.

mblais
02-15-2010, 09:46 AM
Actually I'm looking for timer functionality, not clock time.

Some of the switches on my controller are not well debounced, and often send two or more MIDI messages for a single button press.

My scripts need to examine the time interval between two identical incoming MIDI messages, and throw away the duplicates that come in "too quickly" (i.e. caused by switch bounce, not by two actual presses).

Peace,
RashaMatt

Jeff
02-23-2010, 08:18 PM
Interesting request. There isn't a system variable that has "wall clock" time
but you can get close to that with the "loopFrame" variable. loopFrame has
the frame/sample of the current playback position in the loop, it starts at 0 and goes up to 1 minus the total frame count. For example, at 44.1K a 2 second loop would be 88200 frames (a frame is a stereo sample). loopFrame
starts at 0 increments to 88199 then back to zero.

So you can use this to debounce your keys, the trick is that you have
to detect the loopback from the last frame back to zero

Another way to approach this is by using the !multiclick option. This
is documented in the scripting manual. Usually we use this to get
extra behavior for secondary clicks, but in your case you could use it
to ignore secondary clicks.


!name Debounced Record
!multiclick 500

# just for grins let's keep track of the number of bounces
Variable clicks 0
Record
end

Label click
# came in again, ignore
set clicks clicks + 1
end

Label endClick
# 500 milliseconds has gone by
if clicks > 0
Message Ignored $clicks extra clicks
endif
end