Applescript and Mainstage

ryanh92

Registered
kinda new to applescript so please bear with me. In mainstage, there are scripts to control iTunes such as play/pause song etc. so, in short, you can start a song from iTunes by pressing a button on your midi controller. i want to start a midi file the same way you can start a song from iTunes. However, since iTunes is incapable of playing midi files, i would need to script it to play from quicktime. I've had no such luck from google in trying to find a solution or anything even quicktime related (other than movie files). So how would i go about scripting quicktime to start play a midi file? and if this isn't possible through quicktime, are there any suggestions on what program to use, if any, that would work? Thanks.
 

Mikuro

Crotchety UI Nitpicker
Code:
tell application "QuickTime Player 7"
	open POSIX file "/path/to/your/file.mid"
	play document 1
end tell
For some reason QuickTime Player X will not open midi files, so you need to have QuickTime Player 7 installed, or an alternative player such as NicePlayer. If you use NicePlayer, simply replace "QuickTime Player 7" with "NicePlayer" and the same script will work.
 

ryanh92

Registered
awesome! works perfectly. thanks a lot! maybe you can answer one more quick related question for me. i also have midi files that control patch changes in my guitar effects pedal. Logic recognizes all the changes when i send the file into it. Quicktime doesn't seem to recognize them. Is there another program that would read these events and trigger the patch changes to my pedal? or maybe a way to start logic playback by a script?
 

Mikuro

Crotchety UI Nitpicker
Hmm. I don't know enough about midi to say which players would support that, and I don't have Logic, so I can't check its scripting support.

My GUESS would be that Logic would support similar phrases in AppleScript. "open <file>" is virtually universal. "document <x>" is virtually universal. The "play" command is natural for any program that deals with audio or video files. Have you tried just changing it to say tell application "Logic" ?

As a general AppleScript tip, you can see any program's scripting dictionary by opening the program file with AppleScript Editor (either drag the application to the Script Editor's Dock icon, or go to File > Open Dictionary).

If Logic has no AppleScript support whatsoever, you can, as a sort of last resort, use keystroke and/or mouse click simulation. Many applications use the space bar to play/pause, which could be triggered in AppleScript like so:
Code:
tell application "Logic" to activate
tell application "System Events"
keystroke " "
end tell
Replace " " with whatever keystroke triggers playback in logic. If it's a combination, you can say something like:
Code:
keystroke "p" using command down
 

ryanh92

Registered
no such luck with logic. can't write scripts for it. i found an application called Rondo that is exactly what i need. Sweet MIDI Player also works. i need it to basically do the same thing the quicktime script did. unfortunately there isn't a dictionary for it in the editor so i don't know if i can write scripts for it or not. any ideas? sorry to keep asking so much but i really do appreciate all the help i'm getting.
 
Last edited:

Mikuro

Crotchety UI Nitpicker
If there's no scripting support, my advice would be to do keystroke simulation like I mentioned before. I checked the Rondo demo, and this seems to work:
Code:
tell application "Rondo"
	open POSIX file "/Volumes/Rondo 3.1/Sample MIDI Files/Moonlight.mid"
	activate
	tell application "System Events" to keystroke " "
end tell
 
Top