Hi guys,
I'm building a surface with a complete set of Clip Gain utilities. I'm trying to create a Toggle button that Toggles Bypass / Unbypass.
After selecting a clip or multipe clips, it currently will bypass Clip Gain. However I want it to check whether it's active (in which case the popdown selector to be clicked will be ["Clip Gain, Bypass"] or already bypassed (in which case the popup to be chosen will be ["Clip Gain, Unbypass"]
All help appreciated.
sf.ui.proTools.appActivateMainWindow();
var EditorWin = sf.ui.proTools.windows.whoseTitle.startsWith("Edit:").first;
var EditorWinFrame = EditorWin.frame;
var mousePos = sf.mouse.getPosition().position;
EditorWin.popupMenuSelect({
relativePosition: { x: mousePos.x - EditorWinFrame.x, y: mousePos.y - EditorWinFrame.y },
isRightClick: true,
menuPath: ['Clip Gain', 'Bypass'];
//I want to toggle between Bypass and Unbypass ['Clip Gain', 'Unbypass'];
});
- Kitch Membery @Kitch2020-05-29 03:26:24.616Z
Hi Simon!
For toggling clip gain bypass of more than one selected clip you can use this;
function toggleClipGainBypass() { var menuItemBypass; var menuItemUnbypass; if ((menuItemBypass = sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Bypass")).exists) menuItemBypass.elementClick(); else if ((menuItemUnbypass = sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Unbypass")).exists) menuItemUnbypass.elementClick(); } sf.ui.proTools.clipDoForEachSelectedClip({ action: toggleClipGainBypass });
Rock on!
- SIn reply toSimon_Franglen⬆:Simon Franglen @Simon_Franglen
Hi @Kitch, I had a 'Doh' moment when I looked at your script. I'd never looked in the Menu bar before for clip gain, I'd only ever done it by right click.
So purely because I want to learn how to do this correctly,
IF I'd been trying to use the right click dropdown menu, would I integrate the same command this way? and does 'popupMenuItem' exist?
EditorWin.popupMenuSelect({
relativePosition: { x: mousePos.x - EditorWinFrame.x, y: mousePos.y - EditorWinFrame.y },
isRightClick: true,function toggleClipGainBypass() {
var popupMenuItemBypass;
var popupMenuItemUnbypass;
if ((popupMenuItemBypass = sf.ui.proTools.popupMenuItem("Clip Gain", "Bypass")).exists)
popupMenuItemBypass.elementClick();
else if ((popupMenuItemUnbypass = sf.ui.proTools.popupMenuItem("Clip Gain", "Unbypass")).exists)
popupmenuItemUnbypass.elementClick();
}sf.ui.proTools.clipDoForEachSelectedClip({
action: toggleClipGainBypass
});Kitch Membery @Kitch2020-05-30 10:45:10.257Z
Hi Simon!,
Checking the popup menu items with the right click dropdown method is a little more dificult to do. I'll have to have a think about it and get back to you. And for what it's worth I have about 100 'Doh' moments a day :-)
The reason I chose to do it the way I did in my previous post was because if more than one clip is selected, the script has to iterate through the clips one by one so that it can check the clip gain bypass state for each clip. Doing this with the right click menu would esentially be doing the same thing.
PS... Crazy you messaged me just now as I've been working on the "Chord Stamp" surface you've inspired. I still have a long long way to go but it is gonna make entering chords in Pro Tools a much more fun experience. :-)
Rock on!
- SIn reply toSimon_Franglen⬆:Simon Franglen @Simon_Franglen
Glad I'm in good company. Can't wait to see the Chord surface. We're designing a whole load of GUIs for these at the moment. I'll share as I get them ready for grownups
Kitch Membery @Kitch2020-05-30 11:02:04.740Z
Nice!
- SIn reply toSimon_Franglen⬆:Simon Franglen @Simon_Franglen
@Kitch
The script is great however:
One problem with the checking each clip in turn is that it toggles each state as you've written it so…Since I wanted to have two buttons on the surface 'Bypass' and 'Unbypass', I initially tweaked to make two scripts. They addressed each clip, checked its status and then changed it if needed. It checks each one manually, which could take a long time if you had a set of sliced up drums. Here's Unbypass:
function toggleClipGainBypass() {
var menuItemBypass;
var menuItemUnbypass;
if ((menuItemUnbypass = sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Unbypass")).exists)
menuItemUnbypass.elementClick();
;
}sf.ui.proTools.clipDoForEachSelectedClip({
action: toggleClipGainBypass
});This was way too slow for a hundred clips.
So…
For the Bypass script, i tweaked it to ignore the next clip function, and instead first look for 'Unbypass' in the menu (which would be thrown by any clip that had Clip Gain Bypassed. If it was there, click that. This would set the state of all selected clips to 'Unbypassed' and the menu would now have 'Bypass' as the option.
Then Click 'Bypass' to make all the clips bypassed.Likewise the 'unbypass' script would look for 'Bypass' first, if that was present, it would then click Bypass, followed by 'Unbypass'.
I tried tweaking the script to first look for 'Unbypass' - which is the menu status if any clip in a selected group is already bypassed etc…PROBLEM:
For some reason, SF does not see the changed menu item.
sf.ui.proTools.appActivateMainWindow();function toggleClipGainBypass() {
var menuItemBypass;
var menuItemUnbypass;if ((menuItemUnbypass = sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Unbypass")).exists) menuItemUnbypass.elementClick()
}
;
sf.ui.proTools.menuClick({
menuPath: ["Clip", "Clip Gain", "Bypass"]
});Throws a 'Could Not Find Menu Item' error with the bottom line.
Wassup?
Kitch Membery @Kitch2020-06-01 16:13:34.933Z
Yeah that would take forever! Unfortunatly I think that is the only way to toggle each clip independently. However there is a workaround if you are using two buttons one for Bypass and another for Unbypass.
With this script;
function selectClipGainMenuState(menuItem) { sf.ui.proTools.menuClick({ menuPath: ["Clip", "Clip Gain", menuItem], }); } function setClipGainBypassState(state) { if (state === 'Bypass') { if (sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Unbypass").exists) { selectClipGainMenuState('Unbypass'); selectClipGainMenuState('Bypass'); } else { selectClipGainMenuState('Bypass'); } } else if (state === 'Unbypass') { if (sf.ui.proTools.getMenuItem("Clip", "Clip Gain", "Bypass").exists) { selectClipGainMenuState('Bypass'); selectClipGainMenuState('Unbypass'); } else { selectClipGainMenuState('Unbypass'); } } } //Edit this line to be either 'Bypass' or 'Unbypass' setClipGainBypassState('Bypass');
Just edit the last line to be
setClipGainBypassState('Bypass');
to bypass orsetClipGainBypassState('Unbypass');
to unbypass.- SSimon Franglen @Simon_Franglen
That does it exactly what I want. I can select a clump of clips and have them quickly switch, which is what we do normally with the mouse.
Kitch Membery @Kitch2020-06-01 17:22:55.822Z
Sweet!! Glad to be of service :-)
- SSimon Franglen @Simon_Franglen
Thank you. One last question…
I'm building Clip Presets shortcuts. I need to check that the Clip Preset window is open. The shortcut toggles it. (Opt-6)
Unfortunately PT uses a check mark in the Menu [View / Other Displays / Clip Effects] - is there a quick way to see the Check mark or check if the window is open before running a script?
Kitch Membery @Kitch2020-06-01 18:08:37.143Z2020-06-01 18:18:12.090Z
This should do it :-)
if (sf.ui.proTools.getMenuItem('View', 'Other Displays', 'Clip Effects').isMenuChecked) { log('is checked') } else { log('is not checked') }
- SSimon Franglen @Simon_Franglen
Awesome Hombre, thank you.
- In reply toKitch⬆:BBlake Bunzel @Blake_Bunzel
Just wondering, if I wanted to use this script to simply toggle the Clip Gain menu item from Bypass to Unbypass (and vice versa) with the same button/trigger, what would be the best way to modify this?
- BBlake Bunzel @Blake_Bunzel
Nevermind! I just got it removing a couple of lines from the code.
- In reply toSimon_Franglen⬆:
Kitch Membery @Kitch2020-06-01 16:23:52.557Z
BTW Simon... On a side note, if you want to enter a block of code into the forum, you can put a line of three back ticks ```` , then on the next line add the code you want to display, follwed by another line of 3 back ticks ``` The "back tick" key is the key below the Escape key on a mac keyboard. If you just want to add code into a line like in the last two lines of my above post just add one back tick before and after the code.
I hope that script works for you.
Rock on!- SSimon Franglen @Simon_Franglen
sf.ui.proTools.appActivateMainWindow(); //Check if Clip Preset Window is Open, if not, open it. if (sf.ui.proTools.getMenuItem('View', 'Other Displays', 'Clip Effects').isMenuChecked) { } else { sf.keyboard.press({ keys: "alt+numpad 6", }); } //Select Clip Preset By Name sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Librarian menu').first.popupMenuSelect({ menuPath: ["Telephone"], //Close the Clip Preset Window }); sf.keyboard.press({ keys: "alt+numpad 6", });
Like that…?
Kitch Membery @Kitch2020-06-01 18:42:24.135Z
Nailed it! Nice work.
And if you wanted to reuse that script you could turn it into a function like this.
function selectClipEffectsPreset(preset) { //Activate Protools sf.ui.proTools.appActivateMainWindow(); //Check if Clip Preset Window is Open, if not, open it. if (sf.ui.proTools.getMenuItem('View', 'Other Displays', 'Clip Effects').isMenuChecked) { } else { sf.keyboard.press({ keys: "alt+numpad 6", }); } //Select Clip Preset By Name sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Librarian menu').first.popupMenuSelect({ menuPath: [preset], //Close the Clip Preset Window }); sf.keyboard.press({ keys: "alt+numpad 6", }); } //Select preset here selectClipEffectsPreset('Telephone');
- SSimon Franglen @Simon_Franglen
Absolutely. I feel a Prompt coming on.
Here's the draft surface it'll be going into, still needs a few tweaks
https://www.dropbox.com/s/271pzhjyekdmzt6/Screenshot 2020-06-01 19.53.08.png?dl=0Kitch Membery @Kitch2020-06-01 21:52:46.333Z
Love it!!!!!