Countdown
For conferences, or for rocket launches, a frequent request is a countdown timer that can be displayed on a screen for the presenters. This chapter explores one way to achieve this with a minimum of fuss.
Here it is in action:
How It Works
The workspace uses a Text cue to display a time, and several other cues which manipulate the content and style of that Text cue while it’s running. The workspace is broken down into four Group cues for the basic functions: set/reset, start/resume, stop/pause, and the timer itself.
The first cue in the workspace is a Wait cue numbered set
. The action of this
cue will be used for the duration of the countdown clock, so set it for however
long you want the countdown timer to last.
Set/Reset Timer
The next cue in the workspace is a Group cue, set to “start all children simultaneously,” containing a number of cues which set up the timer:
The first three cues are Stop cues which stop the timer in case it’s running. Next is an Arm cue which is necessary because pausing the timer uses a Disarm cue, so this cue ensures a clean reset if the timer was paused. Next are four Network cues which set up the starting properties of the Text cue.
Set up the timer variable
/cue/var/name "#/cue/set/duration#"
A Memo cue below, numbered var
is used to store the remaining time of the
timer which will be updated once per second as the timer runs. During the setup
stage, we set the name of that cue to the total number of seconds that our timer will run. #/cue/set/duration#
is an OSC query, which grabs the duration of the cue numbered set
. In total, this OSC commands sets the name of cue var
to the duration of cue set
.
Set the length of the color fader
/cue/color/duration #/cue/set/duration#
As the timer cue runs, it fades from green to red. The cue which handles that
fade is numbered color
, so this OSC command sets the duration of the color
fader to the duration of cue set
, creating a smooth fade from start to finish.
Set the font of the timer cue
/cue/clock/liveText/format/fontFamilyAndStyle "Courier" Regular
When the timer is paused, it’s show in italics as a visual reminder that it’s paused. This cue sets the timer to show in regular non-italic Courier.
Set the starting color of the timer cue
/cue/clock/liveText/format/color 0 1 0 1
This sets the initial green color for the timer cue.
The next cue is a Script cue which formats the duration of the timer into the familiar HH:MM:SS format, and sets the timer Text cue to show the starting time.
Here’s the script:
tell application id "com.figure53.QLab.4" to tell front workspace
set totalSeconds to q name of cue "var"
set theHours to (totalSeconds div 3600)
set theRemainderSeconds to (totalSeconds mod 3600)
set theMinutes to (theRemainderSeconds div 60)
set theRemainderSeconds to (theRemainderSeconds mod 60)
if (count characters of (theHours as text)) = 1 then
set theHours to "0" & (theHours as text)
end if
if (count characters of (theMinutes as text)) = 1 then
set theMinutes to "0" & (theMinutes as text)
end if
if (count characters of (theRemainderSeconds as text)) = 1 then
set theRemainderSeconds to "0" & (theRemainderSeconds as text)
end if
set theTimeString to theHours & ":" & theMinutes & ":" & theRemainderSeconds as text
set live text of cue "clock" to theTimeString
end tell
Most of the script is just about the formatting, and then the last line sets the text of the timer Text cue to the formatted time.
Finally, a Start cue starts the timer Text cue so that the timer is displayed, and a Load cue loads the rest of the cues in the timer Group so that the timer starts smoothly.
Start/Resume Timer
This Group contains a Network cue to format the timer to regular, non-italic text, a Start cue to start the Script which does the actual counting down, a Start cue to start the color fader, and an Arm cue which re-arms the cue that the “stop/pause” Group will disarm.
Stop/Pause Timer
This Group pauses the timer by disarming the Start cue that keeps the countdown loop running. Disarming that cue prevents the loop, so the countdown freezes in place. The Group also contains a Network cue to italicize the text of the timer, for a visual reminder that the timer is paused, and a Pause cue to pause the color fader.
Timer Parts
This Group is where the real action happens. First is a Script cue named “tick”, whose job it is to “tick” down the timer by one second. It also makes sure that the time is formatted nicely, and if the timer reaches zero it displays a “time’s up” message. Here’s the script:
tell application id "com.figure53.QLab.4" to tell front workspace
set totalSeconds to q name of cue "var"
set theHours to (totalSeconds div 3600)
set theRemainderSeconds to (totalSeconds mod 3600)
set theMinutes to (theRemainderSeconds div 60)
set theRemainderSeconds to (theRemainderSeconds mod 60)
if (count characters of (theHours as text)) = 1 then
set theHours to "0" & (theHours as text)
end if
if (count characters of (theMinutes as text)) = 1 then
set theMinutes to "0" & (theMinutes as text)
end if
if (count characters of (theRemainderSeconds as text)) = 1 then
set theRemainderSeconds to "0" & (theRemainderSeconds as text)
end if
set theTimeString to theHours & ":" & theMinutes & ":" & theRemainderSeconds as text
set live text of cue "clock" to theTimeString
set totalSeconds to totalSeconds - 1
if totalSeconds < 0 then
set armed of cue "loop" to false
set live text of cue "clock" to "Time's Up!"
else
set q name of cue "var" to totalSeconds
end if
end tell
As before, most of the script is just about the formatting. Near the end, the script sets the text of the timer Text cue, then subtracts 1 from the time remaining, checks to see if the timer is at zero, and acts accordingly.
The Script cue auto-continues to a Start cue which restarts the Script cue. The pre-waits of the Script cue and Start cue add up to one second, which has the result of one “tick” occurring every seconds. While it seems more logical to simply put a 1 second pre-wait on the Start cue, that prevents the loop from working because it causes QLab to attempt to restart the Start cue while it’s still running. Splitting up the pre-wait like this allows the Start cue to complete fully before the Script cue’s auto-continue tries to restart it.
Next is the Memo cue var
which the Script cue uses to keep track of the
countdown time.
Next is a Network cue which fades the color of the timer Text cue from green to red over the duration of the countdown. This Network cue works in an interesting way:
This cue uses the two-dimensional fade capability of Network cues to gradually adjust the red and green components of the color of the timer Text cue.
The OSC message to set the color of a Text cue uses four arguments for R, G, B,
and A (alpha). At the start of the fade, indicated by the green circle in the
preview area, the #x#
variable is at 0
and the #y#
variable is at 1
, so
the color of the cue is 0% red, 100% green, 0% blue, and 100% opaque. Over the
duration of the fade, #x#
fades up to 1
and #y#
fades down to 0
resulting in a final color of 100% red, 0% green, 0% blue, and 100% opaque.
The final cue in this Group is the Text cue which is itself the timer. Perhaps amusingly, this cue does pretty much nothing by itself.
If This All Seems Like A Bit Much
Different situations call for different solutions. If the solution above feels a little complicated for your needs, another approach is to simply play a video or audio recording that counts time down or up. Included in the download links above are several versions of exactly that, which you can use freely.
The videos count down to or up to fifteen minutes, and the audio recordings count down to or up to one minute. If you need less time, just set the start time of your cue to clip off what you don’t need.