Sending OSC via AppleScript

772 views
Skip to first unread message

Alexander (Mailing List) Taylor

unread,
Sep 24, 2020, 12:29:11 PM9/24/20
to ql...@googlegroups.com
Hi All,

Is there a way to send an OSC command directly from AppleScript? I want to sent something like /cue/eventName*/liveText “Hello, World!”. Is that possible without writing to a network cue and then starting it? I’m trying to not disturb the save state of the workspace.

Thanks,
Alexander

The Right-To-Know Law provides that most e-mail communications to or from School District employees regarding the business of the School District are government records available to the public upon request. Therefore, this e-mail communication may be subject to public disclosure.

micpool

unread,
Sep 24, 2020, 12:44:33 PM9/24/20
to QLab

set myOSC to "/cue/eventName*/liveText " & quoted form of "\"Hello World!\""

do shell script "echo " & myOSC & " | nc -u -w 0 127.0.0.1 53535"

Alexander (Mailing List) Taylor

unread,
Sep 24, 2020, 12:47:00 PM9/24/20
to ql...@googlegroups.com
Perfect, thanks!

Alexander

On Sep 24, 2020, at 12:44 PM, micpool <m...@micpool.com> wrote:

Caution - This email is from outside ORCSD. Do not click links or open attachments unless you recognize the sender and know the content is safe.
--
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/3cb6f20b-2a14-40dd-8f27-dfbaba268d09n%40googlegroups.com.

micpool

unread,
Sep 24, 2020, 1:55:14 PM9/24/20
to QLab
Before some else points this out

There is no need to use OSC to do this. You can script it directly

tell application id "com.figure53.QLab.4" to tell front workspace
set theselected to cues whose q number begins with "eventName"
repeat with eachcue in theselected
set the live text of eachcue to "Hello World"
end repeat
end tell

TMS

unread,
Feb 6, 2021, 3:27:57 PM2/6/21
to QLab
I'm very interested in getting qlab to send out the names of it's patches (audio, midi, and network would each be great) over osc.
The end result I'm looking for is to repeatedly send a message out a network cue to the effect of /n/audiopatchname/1 "(Name of Audio Patch 1)", etc...

I patched a few audio destinations into the workspace and then send the query from osculator to the local host address of qlab, but looks like qlab is replying with only the word "data" and an empty list... what's my problem?

micpool

unread,
Feb 6, 2021, 5:09:12 PM2/6/21
to QLab
If its not in the QLab OSC dictionary......
Where did you find audiopatchname in it?

Mic

Traveling Monkey

unread,
Feb 6, 2021, 5:33:25 PM2/6/21
to ql...@googlegroups.com

What I did find in the dictionary is the querry  /settings/audio/outputChannelNames

It is described as a list that includes the the patch and custom names of the devices:


Read-only; return a JSON dictionary of output names for Audio or Mic output patches. The keys in the dictionary are the patch numbers, and the values are dictionaries of output channel numbers and names. If a given patch does not have customized output names, that patch will not be included in the dictionary.
                             
Nils Erickson
Live & Location Audio
www.TravelingMonkeySound.com 707.636.4042 (office)
617.921.5437
(cell)


micpool

unread,
Feb 6, 2021, 6:13:42 PM2/6/21
to QLab
Custom names are the cue output custom names, for each patch number. E.g Patch 1, cue output 1, Drums L

micpool

unread,
Feb 6, 2021, 6:21:36 PM2/6/21
to QLab
Also, even if the patch names were part of the data returned, JSON strings need to be parsed before the info in them is useful.  This is not something that can be done  easily within QLab itself.

micpool

unread,
Feb 6, 2021, 7:42:37 PM2/6/21
to QLab
However, once again, UI scripting can do what you want, here's a quick edit of a Rich Walsh script, that originally got the network patch names and will now get the device names for audio patch 1-8

global dialogTitle

set dialogTitle to "Report audio patch names "


set upArrow to ASCII character 30 -- This seems to save quite a few Apple events as System Events asks QLab every time what ASCII character 30 is

set downArrow to ASCII character 31


-- Check that UI element scripting is possible


if checkUIElementsEnabled() is false then return


-- Check QLab is running


tell application "System Events"

set qLabIsRunning to exists (processes whose bundle identifier is "com.figure53.QLab.4")

end tell

if qLabIsRunning is false then

display dialog "QLab is not running." with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5

return

end if


-- Check there is a workspace open


tell application id "com.figure53.QLab.4"

try

get front workspace

on error

display dialog "There is no workspace open in QLab." with title dialogTitle with icon 0 buttons {"OK"} default button "OK" giving up after 5

end try

end tell


-- Main routine


tell application id "com.figure53.QLab.4"

activate

end tell


tell application "System Events"

tell (first application process whose bundle identifier is "com.figure53.QLab.4")

-- Show the preferences

if name of front window does not end with "Settings" then

keystroke "," using {command down}

end if

delay 0.1 -- Short delays between keystrokes seem to be necessary for stability

-- Bodge: go to the top of the list of tabs on the left (these buttons do not appear to be UI-scriptable)

repeat 9 times

keystroke upArrow

delay 0.1

end repeat

-- Click down to display the "Network" tab

repeat 1 times

keystroke downArrow

delay 0.1

end repeat

-- Get the patch names

set audioPatchNames to {}

repeat with i from 1 to 8

set end of audioPatchNames to value of pop up button i of front window

end repeat

-- Hide the preferences

click button "Done" of front window

-- Return list of names

return audioPatchNames

end tell

end tell


-- Subroutines


on checkUIElementsEnabled()

tell application "System Events"

if not UI elements enabled then

tell application "System Preferences"

activate

reveal anchor "Privacy_Assistive" of pane id "com.apple.preference.security"

display dialog "UI scripting failed! You need to adjust your privacy settings…"

end tell

return false

else

return true

end if

end tell

end checkUIElementsEnabled



Mic Patch names would substitute

set micPatchNames to {}

repeat with i from 9 to 16

set end of micPatchNames to value of pop up button i of front window

end repeat

-- Hide the preferences

click button "Done" of front window

-- Return list of names

return micPatchNames


Since QLab 4.6 there is no fixed table size for network cues so Rich's original script needs a small tweak 

repeat 9 times

keystroke upArrow

delay 0.1

end repeat

-- Click down to display the "Network" tab

repeat 4 times

keystroke downArrow

delay 0.1

end repeat

-- Get the patch names

set oscPatchNames to {}

repeat with i from 1 to (number of rows of table 1 of scroll area 2 of front window)

set end of oscPatchNames to value of text field 1 of UI element 2 of row i of table 1 of scroll area 2 of front window

end repeat

-- Hide the preferences

click button "Done" of front window

-- Return list of names

return oscPatchNames



Reply all
Reply to author
Forward
0 new messages