How to make simple "spot" script for Soundtrack pro?

Using Applescript, I’m trying to spot an audio file to the playhead of the open multitrack document. This is a small piece of a larger script.

I’ve tried doing it in Soundtrack Pro then saving as an Applescript, but for some reason the option is grayed out. I’ve also tried countless ways with terms from the Applescript dictionary. Although I’ve struggled for hours, it’s probably very simple. I’m wondering, what is the script for this?

Script so far:

tell application "Soundtrack Pro"
	activate
	
	tell track {name:"Track 1"} of multitrack document {name:"Untitled"}
		spot file "MacintoshHD:Users:dk:Desktop:___Current Assets:Untitled Recording 247.wav"
	end tell
	
end tell

This compiles but upon running returns the error: “Can’t get file “MacintoshHD:Users:dk:Desktop:___Current Assets:Untitled Recording 247.wav” of track {name:“Track 1”} of multitrack document {name:“Untitled”}.” .

Thank you very much for your help!

Hi,

an element can be referenced either by name or by index, AppleScript recognizes automatically the mode.


tell application "Soundtrack Pro"
	activate
	tell track 1 of multitrack document 1
		spot file "MacintoshHD:Users:dk:Desktop:___Current Assets:Untitled Recording 247.wav"
	end tell
end tell

or


tell application "Soundtrack Pro"
	activate
	tell track "Track 1" of multitrack document "untitled"
		spot file "MacintoshHD:Users:dk:Desktop:___Current Assets:Untitled Recording 247.wav"
	end tell
end tell

Thanks for the tip!

Still doesn’t seem to work though :confused:

Another iteration I’ve tried is removing the word “file” after “spot.” So the script is:


tell application "Soundtrack Pro"
	activate
	tell track "Track 1" of multitrack document "Untitled"
		spot "MacintoshHD:Users:dk:Desktop:___Current Assets:Untitled Recording 247.wav"
	end tell
end tell

This is good because no error message is shown. It also, however, doesn’t seem to do anything more than activate soundtrack pro - no file is added to the track.

Other ideas?

Thanks!

the manual of SoundTrack Pro says that you can spot only clips which are already added to the document
In AppleScript dictionary an document has file elements which you can refer to

That seems to explain the error message for sure.

Now, to add files to the document… I guess I’m not exactly sure what that means. Manually, I can use the “Browser” tab to find the file on the computer and spot it from there. I guess this is a different method though?

How might I add a file/sound clip to the Soundtrack Pro document with an Applescript? I already have a loop set up that selects each sound clip and its info subsequently in a folder, so it’s just a matter of getting those sound clips into Soundtrack pro.

Sorry for my ignorance - yes I suck at ST Pro and Applescript.

Thank you so much!