Python-rtMIDI & AppleScript/JavaScript

Not really a question about Open Stage Control, but as I’ve come to understand, the software makes use of this Python-rtMIDI thingy. Hoping that someone would be willing to share some perspective, I’m asking this: Is it possible to trigger a MIDI note message with Applescript (or Javascript) through Python-rtMIDI? I’m trying to write a script that interacts with the GUI of my DAW (clicks, drag&drop mouse actions, keystrokes) and here and there I’d like to add lines that can trigger a MIDI note message.

Example (applescript):

-- delay variables
set delayOne to 0.1
set delayTwo to 0.3

-- click before drag
set firstX to 544
set firstY to 48
do shell script "eval $(/usr/libexec/path_helper -s); cliclick dd:" & firstX & "," & firstY
delay delayOne

-- drag to new location and release
set secondX to 507
set secondY to 287
do shell script "eval $(/usr/libexec/path_helper -s); cliclick du:" & secondX & "," & secondY
delay delayTwo

-- send MIDI note message with Python-rtMIDI
port
note
channel
velocity

Thank you!

You can send midi messages directly from the custom modules, I don’t think there any interest in doing it from an applescript subprocess. It seems you’re only using applescript to call shell scripts, which you can already do in the custom module

var { exec } = nativeRequire('child_process')

// etc..

I feel bad that I didn't take the time to write back immediately. Please forgive me.

I know. You taught me in another thread!

Nope. I need to use applescript to make different applications execute different actions.
Look at the script listed below. Only the last two blocks call Shell Scripts; the other blocks perform actions that directly talk to applications. Is this also possible with Custom Module? I mean, can a Custom Module contain instructions that, say, make different apps get the focus or perform different actions like the ones in the "SizeUp Actions" block (in my script)?

-- script cubase.SE-open in Preview

-- delay variables
set delayZero to 0.01
set delayOne to 0.3
set delayTwo to 0.6
set PageDelay to 2

-- set focus to the Score Editor in Cubase
tell application "System Events"
	tell application process "Cubase 10.5"
		perform action "AXRaise" of (first window whose name contains "Scores")
		delay delayZero
		tell application "Cubase 10.5" to activate
		delay delayZero
	end tell
end tell

-- print with command+shift+p (must be created through the Key Commands window)
tell application "System Events"
	keystroke "p" using {command down, shift down}
	delay delayOne
end tell

-- SizeUP actions
tell application "SizeUp" to do action Next Monitor
delay delayTwo
tell application "SizeUp" to do action Center
delay delayOne

-- PDF dropdown
set firstX to 721
set firstY to 597
do shell script "eval $(/usr/libexec/path_helper -s); cliclick c:" & firstX & "," & firstY
delay delayZero

-- Open in Preview
set secodX to 737
set secodY to 623
do shell script "eval $(/usr/libexec/path_helper -s); cliclick c:" & secodX & "," & secodY
delay delayZero

I feel bad that I didn't take the time to write back immediately. Please forgive me.

No problem at all

Is this also possible with Custom Module?

No, but it should to be possible to execute applescript from the custom module using something like this library.

1 Like