Bounce script: Create selection, record arm tracks, press record
Hi guys,
I'm working on a bounce script that is supposed to:
-
Create a selection between my START end END markers
-
Select the audio tracks onto which my mix versions are going to be recorded
-
Record enable these tracks
-
Press record
As for 1, the script must be able to find the START and END markers by name instead of number. It seems that most of the scripts that could do this were broken by a Pro Tools update at some point, and now I can't find a way to do it.
As an alternative I now use a script by @Kitch to call on a marker selection called BOUNCE, that has the same start and end times as my START and END markers. It works, but it requires me to manually create the BOUNCE marker selection, which I would rather like to avoid.
As for 2, I found a script by @Andrew_Downes that beautifully uses wildcards to select tracks with names that can differ slightly. My bounce record tracks are typically named MAIN MIX 1.0, SINGBACK MIX 1.0, INSTRUMENTAL MIX 1.0 or MAIN MIX 1.0 WITHOUT LIMITER. The word they have in common is MIX, which never occurs elsewhere in my sessions. So using this script I can have all these tracks selected at the same time. Neat!
As for 3, the same script is supposed to record enable the selected tracks by using:
sf.keyboard.press({ keys: 'shift+r' });
But it doesn't work for me. I tried inserting a wait in-between selecting and arming the tracks, but no luck. Manually pressing Shift+R on my keyboard works, so I don't know why the script is not.
As for 4, I'm just using the standard Record macro, which probably works fine if there are any record enabled tracks present. Which there aren't. So the script ends with a timeline selection, a track selection and a blinking red Record button.
I would love if someone could help me with 1 and 3 so I can get this script to fly.
Here's the full script:
// Activate the selection named BOUNCE, which in my sessions is the same as creating a selection between the START and END markers
// Script by Kitch Membery (@Kitch)
/**
* @param {function} callback
*/
function setupRestore(callback) {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.invalidate();
const isMemoryLocationsWindowOpen = sf.ui.proTools.memoryLocationsWindow.exists;
try {
callback();
} finally {
if (!isMemoryLocationsWindowOpen) {
sf.ui.proTools.menuClick({
menuPath: ["Window", "Memory Locations"],
targetValue: "Disable",
});
}
}
}
/**
* @param {object} obj
* @param {string} obj.name
*/
function selectMemoryLocationByName({ name }) {
setupRestore(() => {
sf.ui.proTools.appActivateMainWindow();
const locations = sf.proTools.memoryLocationsFetchFromGui().collection["List"].map(ml => ml);
let targetLocation = locations.find(location => location.name === name);
sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: targetLocation.number });
});
}
selectMemoryLocationByName({ name: "BOUNCE" });
// Select and record arm the MIX tracks
// Script by Andrew Downes (@Andrew_Downes)
function selectTracksByNameWithWildcard(trackNames = []) {
function matchWildcard(str, rule) {
var escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$", "i").test(str);
}
var allNames = sf.ui.proTools.trackNames;
var namesToSelect = allNames.filter(n => trackNames.some(tn => matchWildcard(n, tn)));
sf.ui.proTools.trackSelectByName({
names: namesToSelect,
deselectOthers: true,
});
}
selectTracksByNameWithWildcard([
'*MIX *',
]);
sf.wait({ intervalMs: 500 });
sf.keyboard.press({ keys: 'shift+r' });
sf.wait({ intervalMs: 500 });
// Press record
// Calling command "Record" from package "Pro Tools" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckp49i4j60000a2100yfwywgf/clcf936ky0000l110ggp9f9bf")
sf.soundflow.runCommand({
commandId: 'user:ckp49i4j60000a2100yfwywgf:ckxz4ti3m000dm110aey6hrsq',
props: {}
});
Thanks!
Jonas