Sunrise Sunset audio triggers

135 views
Skip to first unread message

MJ

unread,
Apr 13, 2022, 12:56:53 PM4/13/22
to QLab
Hello,
Looking for advice on how to program/script audio cues based on Sunrise and Sunset times of day throughout the calendar year.  Needs to be automated, without operator input.
I'm aware that most lighting systems have functions to track sunrise sunset data.  Haven't found that function in qlab yet.

Thank You,
Mike

Message has been deleted

micpool

unread,
Apr 13, 2022, 7:29:54 PM4/13/22
to QLab
Last version had a major error! (as predicted)

I've thrown this together very quickly and it needs to be tested thoroughly before use for all possible timezones and  a range of cities in those timezones, but it's probably  at least half way there to being useful! (It may have major calculation errors and can be improved considerably). It's also easy enough to test for your own location to enable you to be reasonably confident using it.

This script (which you can trigger when the workspace starts, and/or from its own wall clock once a day,  gets the sunrise and sunset times from sunrise-sunset.org and sets wall clocks for SUNRISE and SUNSET cues for next time those times are reached. It also determines whether we are currently in day or night and fires the appropriate cue.

-- Set the Wallclocks to  Sunrise and Sunset times

set theLatitude to 53.8008 --South is minus

set theLongditude to -1.5491 --West is minus 

set theTimeOffset to 0 --Offset to  GMT

set theDST to 1 --0 or 1 for daylight saving time

try

   --get the sunrise and sunset times

   set theURL to "https://api.sunrise-sunset.org/json?lat=" & (theLatitude as text) & "&lng=" & (theLongditude as text) & "&formatted=0"

   set theAstronomical to do shell script "curl  " & quoted form of theURL

   --brute force parse JSON

   set theSunriseHour to (text 4 thru 5 of (word 5 of theAstronomical)) + theTimeOffset + theDST

   if theSunriseHour > 24 then set theSunriseHour to theSunriseHour - 24

   set theSunriseMinute to word 6 of theAstronomical

   set theSunSetHour to (text 4 thru 5 of (word 14 of theAstronomical)) + theTimeOffset + theDST

   if theSunSetHour < 0 then set theSunSetHour to 24 + theSunSetHour

   set theSunSetMinute to word 15 of theAstronomical

   

   --set the wall clocks for next time

   --cue SUNRISE is a cue with it's wall clock Trigger enabled and set to 24 Hours

   --cue SUNSET is a cue with it's wall clock Trigger enabled and set to  24 hour

   set theTime to (time of (current date)) 

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

       set wall clock hours of cue "SUNRISE" to theSunriseHour

       set wall clock minutes of cue "SUNRISE" to theSunriseMinute

       set wall clock hours of cue "SUNSET" to theSunSetHour

       set wall clock minutes of cue "SUNSET" to theSunSetMinute

       

       set theSunSetTime to (theSunSetHour * 3600) + (theSunSetMinute * 60)

       set theSunriseTime to (theSunriseHour * 3600) + (theSunSetHour * 60)

       

       --run the cue which would have run before the current time.

       

       if theTime > theSunSetTime or theTime < theSunriseTime then

           start cue "SUNSET"

       else

           start cue "SUNRISE"

       end if

       

       

   end tell

   

end try


Mic


Reply all
Reply to author
Forward
Sunrise Sunset audio triggers

micpool

unread,
Apr 13, 2022, 7:33:09 PM4/13/22
to QLab
You could also take a look at Power Manager from Dragon Systems Software Limited  which can use  astronomical times  to trigger all sorts of things including scripts.
Mic
On Wednesday, April 13, 2022 at 5:56:53 PM UTC+1 MJ wrote:
Reply all
Reply to author
Forward
0 new messages