Script: Create a new stereo audio track from two adjacent mono audio tracks. Needs one more step…
By Chris Shaw @Chris_Shaw2020-04-22 18:52:58.092Z
As the title says.
I frequently get split stereo files to mix. This script speeds up the workflow of creating a new stereo track from them.
What I'd like to do is copy the output routing of the first source track (bus or physical output) and apply it to the newly created track. Any suggestions?
// This script takes two selected adjacent mono audio tracks, copies the audio, and pastes it into a new stereo track.
// The new track will get it's name from the first selected track but with the last two characters removed.
// (handy if the source tracks are labeled ".L or .R". Delete the last three lines to leave the rename dialog
// open at the end of script execution)
// First clear the UI Cache - otherwise SF throws errors if script is run again
sf.ui.proTools.mainWindow.invalidate();
// Ensure Link Track and Edit Selection is engaged
sf.ui.proTools.menuClick({
menuPath: ["Options", "Link Track and Edit Selection"],
targetValue: 'Enable' //or 'Enable' or 'Toggle'
});
// Ensure track view is set to waveform
sf.ui.proTools.selectedTrack.trackDisplaySelect({
displayPath: ["waveform"],
selectForAllSelectedTracks: true,
executionMode: "Foreground",
onError: "ThrowError",
});
// Select and Copy All Audio
sf.ui.proTools.menuClick({
menuPath: ["Edit", "Select All"],
});
sf.ui.proTools.menuClick({
menuPath: ["Edit", "Copy"],
});
// Invoke "Track -> New..." dialog window
sf.ui.proTools.menuClick({
menuPath: [ 'Track', 'New...' ]
});
// Wait for "New Tracks" window to appear
var ntDlg = sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'New Tracks' }).dialog;
// Select Stereo
sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.popupButtons.whoseTitle.is('Mono').first.popupMenuSelect({
menuPath: ["Stereo"],
});
// Select "Samples"
sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.popupButtons.whoseTitle.is('Samples').first.popupMenuSelect({
menuPath: ["Samples"],
});
// Click "Create" button
sf.ui.proTools.focusedWindow.getFirstWithTitle("Create").elementClick();
//Paste audio
sf.ui.proTools.menuClick({
menuPath: ["Edit", "Paste"],
});
//Move selection to first source
sf.keyboard.press({
keys: "p, p",
});
// Open Track Rename dialog and copy name
sf.ui.proTools.selectedTrack.trackOpenRenameDialog();
sf.ui.proTools.menuClick({
menuPath: ["Edit","Select All"],
});
sf.ui.proTools.menuClick({
menuPath: ["Edit","Copy"],
});
//Close Rename dialog
sf.ui.proTools.focusedWindow.buttons.whoseTitle.is('OK').first.elementClick();
//Move selection to new track
sf.keyboard.press({
keys: "semicolon, semicolon",
});
//Rename track
sf.ui.proTools.selectedTrack.trackOpenRenameDialog();
sf.ui.proTools.menuClick({
menuPath: ["Edit", "Paste"],
});
sf.keyboard.press({
keys: "right, backspace, backspace, return",
});
~~~