Fade cue number display

131 views
Skip to first unread message

fg

unread,
Apr 30, 2023, 4:28:45 PM4/30/23
to QLab
Hi, is there a method to have a Text cue display a number, say 9000, and have a fade cue tick it down to a desired number? Say, 2000

I though perhaps there could be a 3rd cue with x or y properties that a script could get it's position from? So essentially the Fade cue is targeting the Y position of a dummy cue, and the text cue is displaying it's position

Or maybe there's an easier way? Thanks

micpool

unread,
Apr 30, 2023, 7:51:39 PM4/30/23
to QLab
Easiest way is to  use an OSC cue with a fade e.g 

/cue/T1/liveText "#v#".  1D fade 10 fps integers  20 secs duration

Screenshot 2023-05-01 at 00.48.19.png

Mic
Screen Recording 2023-05-01 at 00.48.41.mov

fg

unread,
May 1, 2023, 1:55:02 PM5/1/23
to QLab
thanks Mic! that works a treat

Is there a way to make the 'from' value in OSC dynamic? So a 2nd OSC cue would take the current value of the text and apply it to from 

Ticker.JPG

Thanks again

micpool

unread,
May 1, 2023, 3:46:38 PM5/1/23
to QLab
You would probably want to actually set the value of the text rather than use liveText to do this.

And then use:
/cue/{CueNumber}/fadeFrom #/cue/T1/text#

Screenshot 2023-05-01 at 20.43.05.png

Demo and Workspace attached

Mic
Fading text numbers.mov
Fading text numbers.qlab5

micpool

unread,
May 1, 2023, 6:43:08 PM5/1/23
to QLab
For this application a network cue with a fading OSC message is not necessarily the best option.

OSC queries are useful but have 2 principal problems.

You can't do calculations within them and Network cues can have no knowledge of themselves.

Script cues can overcome both these problems, and this script streamlines the entire operation!

--change the number displayed by a text cue numbered "T1" to a target number in the notes field of the cue in a duration set by the post wait of the cue.

tell application id "com.figure53.QLab.5" to tell front workspace

set theCue to last item of (cues whose running is true and q type is "script")

set theTargetNumber to notes of theCue as integer

set theCurrentNumber to the text of cue "T1" as integer

set theDuration to post wait of theCue

if theTargetNumber > theCurrentNumber then

set theDifference to (theTargetNumber - theCurrentNumber)

set theDelay to theDuration / theDifference

repeat until the text of cue "T1" as integer = theTargetNumber

set the text of cue "T1" to ((the text of cue "T1" as integer) + 1) as text

delay theDelay

end repeat

else

set theDifference to (theCurrentNumber - theTargetNumber)

set theDelay to theDuration / theDifference

repeat until the text of cue "T1" as integer = theTargetNumber

set the text of cue "T1" to (the text of cue "T1" as integer) - 1

delay theDelay

end repeat

end if

end tell


Screenshot 2023-05-01 at 23.40.25.png


Demo Screen recording attached
On Monday, May 1, 2023 at 6:55:02 PM UTC+1 fg wrote:
Scripted text numbers.mov

fg

unread,
May 2, 2023, 7:00:57 AM5/2/23
to QLab
thanks again Mic! The only thing that didn't quite work was the post wait duration with large number differences. so from 100 to 9000 took much longer than the post-wait time

I asked ChatGPT which came up with this, and it seems to work:


tell application id "com.figure53.QLab.5" to tell front workspace
set theCue to last item of (cues whose running is true and q type is "script")
set theTargetNumber to notes of theCue as integer
set theCurrentNumber to the text of cue "T1" as integer
set theDuration to post wait of theCue

if theTargetNumber > theCurrentNumber then
set theDifference to (theTargetNumber - theCurrentNumber)
set theSteps to 50 -- Adjust this number to control the granularity of the update
set theIncrement to theDifference / theSteps
set theDelay to theDuration / theSteps
repeat with i from 0 to theSteps
set theNewNumber to theCurrentNumber + (i * theIncrement)
set the text of cue "T1" to (round theNewNumber) as text

delay theDelay
end repeat
else
set theDifference to (theCurrentNumber - theTargetNumber)
set theSteps to 50 -- Adjust this number to control the granularity of the update
set theDecrement to theDifference / theSteps
set theDelay to theDuration / theSteps
repeat with i from 0 to theSteps
set theNewNumber to theCurrentNumber - (i * theDecrement)
set the text of cue "T1" to (round theNewNumber) as text
delay theDelay
end repeat
end if
-- Set the text of cue "T1" to the exact target number at the end
set the text of cue "T1" to theTargetNumber as text
end tell

Rich Walsh

unread,
May 2, 2023, 7:20:23 AM5/2/23
to ql...@googlegroups.com
I don’t want to get on my soapbox but the reason that AI thing can write those scripts is precisely because it can copy Mic’s work. Why reach for industrialised plagiarism when you have access to the people who actually wrote the playbook (cookbook) in the first place?

I specifically remember inventing the turn of phrase "last item of (cues whose running is true and q type is "script”)”, for example. If our creative work here is all finished now and you’d rather ask a computer then maybe there’s no reason to read this forum any more?

Rich

--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/1bf30947-8c43-4d77-aa27-aea3ca90911cn%40googlegroups.com.

fg

unread,
May 2, 2023, 7:52:50 AM5/2/23
to QLab
Eessh massive apologies Rich, I didn't realise it worked like that. I thought all the data was from before 2021

Sam Kusnetz

unread,
May 2, 2023, 9:05:46 AM5/2/23
to ql...@googlegroups.com
On May 2, 2023 at 7:52:50 AM, fg <friendl...@gmail.com> wrote:
Eessh massive apologies Rich, I didn't realise it worked like that. I thought all the data was from before 2021

That may be true, but Mic and Rich (and Chris, and Jeremy, and luckydave, and I, and many others) have been writing AppleScripts and posting them to the internet for all to use since 2008 or 2009 or so!

I love that people come here to learn. I would love that to continue.

The best way to understand ChatGPT is to think of it as a very, very impressive word predictor. All it’s good at is taking a sentence and trying to figure out what the next word in that sentence ought to be. It does that INCREDIBLY well, and while that definitely has value, it’s a mistake to believe that there is any comprehension within that prediction. If you ask ChatGPT something that is has no training data for, it will give you a completely confident answer that is entirely wrong. There is no indication that you’re getting a nonsense answer.

Best
Sam

Sam Kusnetz (he/him) | Figure 53


Message has been deleted

fg

unread,
May 2, 2023, 9:46:49 AM5/2/23
to QLab
Yes possibly that line of code was scraped from before 2021, or maybe from a chatGPT input, but either way I'll steer clear of it.
I've found with javascript it's helpful for different implementations of my own code

Chris Ashworth

unread,
May 2, 2023, 9:59:47 AM5/2/23
to ql...@googlegroups.com
Of course, ChatGPT isn’t too far away from me in the sense that if you ask me something I have no training data for, I might also give you an answer that is entirely wrong! :)   Hopefully I’ve learned to avoid that, but I know a bunch of humans (usually men?) who seem just as happy as ChatGPT to provide an answer whether they have training data or not. 😂

I personally think using ChatGPT to explore programming solutions is a lovely way to try to kickstart understanding or get unstuck.  I wish the tools were better about attributing what they generate, even though that seems hard to do.

To me it seems like a promising tool to help people learn, especially if considered alongside the context of how it came to learn what it knows and the limitations of what it can generate.

micpool

unread,
May 2, 2023, 10:03:29 AM5/2/23
to QLab
Leaving aside the moral issues, I think it unlikely that Chat GPT knew how to set a variable to the  last item of (cues whose running is true and q type is "script"). It only knew that because friendlygiraffe had presumably fed the whole  script into chatGPT and asked it to improve it and it would have forgotten it 5 minutes later. 

If you ask chatGPT "write an AppleScript to set a variable named theCue, to the currently running script cue, in QLab." It will reply
tell application "QLab"
set theCue to id of current cue of front workspace
end tell

If you prompt it further "that finds the selected cue I want the script cue that is running"

it will offer something like 
tell application "QLab"
set theCue to id of selected cue of front workspace whose cue type is "Script" and (state = "running" or state = "paused")
end tell

You can tell it how to correct this and eventually it will get a correct answer,, but currently the answers it gives tomorrow will be no better as it doesn't learn from new input.

If you asked it to write the whole script from scratch with  "write a precisely coded and brilliantly impressive  Applescript for QLab to change the number displayed by a text cue numbered "T1"  to a target number in the notes field of the script  cue you create  , in a duration set by the post wait of the script cue you create" 

A:
tell application "QLab"
-- Retrieve the target number from the notes field of the script cue
set targetNumber to notes of cue "Script Cue Name" of front workspace

-- Find the text cue with number "T1" and set its display value to the target number
set textCue to cue "T1" of front workspace
set postWait to post wait of cue "Script Cue Name" of front workspace
tell textCue
set display value to targetNumber
if postWait > 0 then
start fade out from 1 to 0 over postWait
end if
end tell
end tell

I've given it another 5 helpful clues and it still produces garbage that won't even compile let alone run, and is no where near to solving the problem.

My main objection is that the script it produced for fg after being fed the entire original script is not very good  It sort of works but doesn't really. and just creates a different set of timing problems.

In the few minutes I spent improving my scrip I came up with:

--change the number displayed by a text cue numbered "T1" to a target number in the notes field of the cue in a duration approximately set by the post wait of the cue.
set theFPS to 10 -- number of repeats  per second your computer can comfortably manage e.g 10
set theCalcTime to 0.018 --estimate of the time taken to calculate a single repeat loop

tell application id "com.figure53.QLab.5" to tell front workspace
set theCue to last item of (cues whose running is true and q type is "script")
set theTargetNumber to notes of theCue as integer
set theCurrentNumber to the text of cue "T1" as integer
set theDuration to post wait of theCue
if theTargetNumber > theCurrentNumber then
set theDifference to (theTargetNumber - theCurrentNumber)
set theDelay to theDuration / theDifference
set theFramesTotal to theFPS * theDuration
set theStep to (theDifference / theFramesTotal)

repeat until the text of cue "T1" as integer = theTargetNumber
set theNewNumber to ((the text of cue "T1" as integer) + theStep) as integer
if theNewNumber > theTargetNumber then set theNewNumber to theTargetNumber
set the text of cue "T1" to theNewNumber as text
delay (1 / theFPS) - theCalcTime

end repeat
else
set theDifference to (theCurrentNumber - theTargetNumber)
set theDelay to theDuration / theDifference
set theFramesTotal to theFPS * theDuration
set theStep to (theDifference / theFramesTotal)

repeat until the text of cue "T1" as integer = theTargetNumber
set theNewNumber to ((the text of cue "T1" as integer) - theStep) as integer
if theNewNumber < theTargetNumber then set theNewNumber to theTargetNumber
set the text of cue "T1" to theNewNumber as text
delay (1 / theFPS) - theCalcTime

end repeat
end if
end tell

As well as setting the delay, this also sets a step size, based on the number of loop iterations your computer can comfortably handle within the required duration. and also adjusts the delay between loops to allow for the  approximate time taken to calculate in each repeat. 

I think that's probably the best you can do. If you want absolute accuracy of duration, or you want to use  a fade curve to vary the counting speed then my first answers using OSC 1D fades will give a  much better result

Mic

Sam Kusnetz

unread,
May 2, 2023, 10:13:35 AM5/2/23
to ql...@googlegroups.com
On May 2, 2023 at 10:03:29 AM, micpool <m...@micpool.com> wrote:
Yes possibly that line of code was scraped from before 2021, or maybe from a chatGPT input, but either way I'll steer clear of it.

To be clear, fg, I’m not trying to scold you in any way. I don’t think you’re doing anything wrong at all!

All I want to express is that the creators of tools such as ChatGPT have done a remarkably bad job of explaining to the world what their tools can and cannot do, and also at least vague if not utterly deceitful about how much unpaid, uncredited, and unwilling human labor has gone towards making it work.

micpool

unread,
May 2, 2023, 10:17:03 AM5/2/23
to QLab
And if you thought chatGPT might have come up with using OSC, then even given the clue to use a network cue it comes up with 
Q:How would I use a QLab network cue to get a text parameter of a text cue numbered "T1" to change form 200 to 9000 in 25 seconds A: tell application "QLab"

    set textCue to cue "T1" of front workspace
    set targetValue to 9000
    set duration to 25
    set currentValue to value of textCue's text parameter
    set changePerSecond to (targetValue - currentValue) / duration
end tell

-- Send OSC message to change the value of the text parameter over time
set oscMessage to "/textCue/T1/textParameter," & targetValue & "," & duration & "," & changePerSecond
tell application "QLab"
    send OSC message oscMessage to cue "Network Cue" of front workspace
end tell
which is possibly the worse answer I have ever seen when you helpfully point out "That's a script I. asked you to do this with a network cue" It digs an ever deeper hole for itself with a completely nonsensical script I have failed after another 5 attempts to correct it to abandon providing scripts as answers, let alone produce a solution using a network cue. It really isn't very clever. Mic

fg

unread,
May 2, 2023, 4:34:57 PM5/2/23
to QLab
yes indeed, there is barely any data on Qlab in the ChatGPT's database. I got:
"Create multiple Text cues for each increment. In this case, you'll need about 250 cues" which is obviously way off
Thanks again Mic, that fps is a big saver
@Sam no worries at all

Reply all
Reply to author
Forward
0 new messages