Hi all,
I'm wondering if there is a way to move midi regions back by a specific value, for example. The number of samples my playback engine is set to. 128, 256 etc etc?
I have made a macro which moves the regions back 1024 samples, this is working but I also want to replicate it with 64, 128 and 256 and wanted to ask if there is a way I can just use a script and type in the number of samples required rather than having to record multiple "numpad minus" gestures.
Thanks, Stuart
sf.ui.proTools.appActivateMainWindow();
//Calling command "Set Grid" from package "SP Pro Tools Package"
sf.soundflow.runCommand({
commandId: 'package:clo6gpfw80009ry101sethrs0',
props: {
value: "Samples",
}
});
//Calling command "SP Pro Tools Nudge 1000 Samples" from package "SP Pro Tools Package"
sf.soundflow.runCommand({
commandId: 'package:clo98g78m002b2210ty49p7k3',
props: {}
});
sf.keyboard.press({
keys: "numpad minus",
});
//Calling command "SP Pro Tools Nudge 10 Samples" from package "SP Pro Tools Package"
sf.soundflow.runCommand({
commandId: 'package:clu4kwk9t00004g10mb58s6nu',
props: {}
});
sf.keyboard.press({
keys: "numpad minus",
});
sf.keyboard.press({
keys: "numpad minus",
});
//Calling command "SP Pro Tools Nudge 2 Samples" from package "SP Pro Tools Package"
sf.soundflow.runCommand({
commandId: 'package:clu4kx43m00014g10vear3cqn',
props: {}
});
sf.keyboard.press({
keys: "numpad minus",
});
sf.keyboard.press({
keys: "numpad minus",
});
- Christian Scheuer @chrscheuer2024-03-27 10:32:49.374Z
This script will use the "Shift" dialog to move the selected content on any track left by 64 samples.
sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Shift...'], }); var shiftWin = sf.ui.proTools.windows.whoseTitle.is(" Shift ").first; shiftWin.elementWaitFor(); shiftWin.radioButtons.whoseTitle.is("Earlier").first.elementClick(); var samplesField = shiftWin.textFields.whoseTitle.is("NumericEntryText").allItems[4]; samplesField.mouseClickElement({ relativePosition: { x: 10, y: 10 } }); sf.keyboard.type({ text: '64' }); shiftWin.buttons.whoseTitle.is("OK").first.elementClick();
You can change the value '64' in the script accordingly to match the number of samples you'd like to move your MIDI clip by.
- SStuart Peck @Stuart_Peck
That's wonderful Christian, thank you very much.
Dustin Harris @Dustin_Harris
piggybacking on @chrscheuer 's reply, here's a version that fetches the buffer size from the Playback Engine window and uses it to set the nudge value in Christian's code:
function getBufferSize() { sf.ui.proTools.menuClick({ menuPath: ['Setup', 'Playback Engine...'], }); const bufferLabel = sf.ui.proTools.windows.whoseTitle.is("Playback Engine").first.popupButtons.allItems[1]; const bufferValue = bufferLabel.title.value.split(" ")[0]; const okButton = sf.ui.proTools.windows.whoseTitle.is("Playback Engine").first.buttons.whoseTitle.is("OK").first; okButton.elementClick(); okButton.elementWaitFor({ waitType: "Disappear" }); return bufferValue } /**@param {string} bufferSize */ function shiftSelectionByEngineBufferSize(bufferSize) { sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Shift...'], }); var shiftWin = sf.ui.proTools.windows.whoseTitle.is(" Shift ").first; shiftWin.elementWaitFor(); shiftWin.radioButtons.whoseTitle.is("Earlier").first.elementClick(); var samplesField = shiftWin.textFields.whoseTitle.is("NumericEntryText").allItems[4]; samplesField.mouseClickElement({ relativePosition: { x: 10, y: 10 } }); sf.keyboard.type({ text: bufferSize }); shiftWin.buttons.whoseTitle.is("OK").first.elementClick(); } function main() { sf.ui.proTools.appActivateMainWindow(); const bufferSize = getBufferSize(); shiftSelectionByEngineBufferSize(bufferSize); } main();
- SStuart Peck @Stuart_Peck
Thanks @Dustin_Harris and sorry for the late reply, That's super helpfull. I'm mostly in 1024 but when mixing I sometimes have to drop things in after I've been given notes or an edit has changed. Thanks again, I'll give that a try