I'm creating scripts to quantise to different amount. I have one for triplet values, however if triplets have been previously selected, applying this script toggles the triplet setting to off.
Is there a way for SF to check whether a variable is already checked on before switching it, or to reset it first?
sf.ui.proTools.appActivateMainWindow();
sf.keyboard.press({
keys: "alt+numpad 0",
});
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.popupButtons.whoseDescription.is('').allItems[2].popupMenuSelect({
menuPath: ["1/2 note"],
});
sf.wait();
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.popupButtons.whoseDescription.is('').allItems[2].popupMenuSelect({
menuPath: ["triplet"],
});
sf.wait();
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.buttons.whoseTitle.is('Apply').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.windowClose();
sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.elementWaitFor({
waitType: "Disappear",
});
- Christian Scheuer @chrscheuer2020-02-23 21:49:43.249Z
Hi Simon.
I'm sorry, your entry here got lost in mail hell.
I can't test this right now since I'm not on a PT computer, but try this:if (sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.popupButtons.whoseDescription.is('').allItems[2].value.invalidate().value !== "1/2 note") { sf.ui.proTools.windows.whoseTitle.is('Event Operations').first.popupButtons.whoseDescription.is('').allItems[2].popupMenuSelect({ menuPath: ["1/2 note"], }); }
Christian Scheuer @chrscheuer2020-03-06 21:47:39.897Z
Hi Simon
Could you get this working?
- SIn reply toSimon_Franglen⬆:Simon Franglen @Simon_Franglen
This almost works. It resets the command to a 1/2 note before selecting the new quantise value, however it does not reset the Triplet Tick below the value.
What I want is for the macro to either check whether the triplet has been ticked, or perhaps reset the Triplet if it is ticked, that way I can use the same macro for any value and just add in a 'tick the triplet' line in there when I need it.I suppose basically I need a command to reset all the value to a default value before selecting
Christian Scheuer @chrscheuer2020-03-19 00:47:16.231Z
This script should do it in the fewest possible steps:
function selectGrid({ value, dotted, triplet }) { var eventOpsWin = sf.ui.proTools.windows.whoseTitle.is('Event Operations').first; var gridButton = eventOpsWin.popupButtons.whoseTitle.is('Combined Quantize').first; var gridValue = gridButton.value.invalidate().value; var gridNoteValueMatch = gridValue.match(/(dotted )?(1\/\d+) note( triplet)?/); var gridNoteValue = gridNoteValueMatch && gridNoteValueMatch[2]; if (gridNoteValue !== value) { gridButton.popupMenuSelect({ menuPath: [value + ' note'] }); } if (!dotted && !triplet) { if (gridValue.indexOf("triplet") >= 0) { gridButton.popupMenuSelect({ menuPath: ['triplet'] }); } else if (gridValue.indexOf("dotted") >= 0) { gridButton.popupMenuSelect({ menuPath: ['dotted'] }); } } else { if (triplet && (gridValue.indexOf("triplet") < 0)) { gridButton.popupMenuSelect({ menuPath: ['triplet'] }); } else if (dotted && (gridValue.indexOf("dotted") < 0)) { gridButton.popupMenuSelect({ menuPath: ['dotted'] }); } } } selectGrid({ value: '1/2', dotted: true, triplet: false });
- SSimon Franglen @Simon_Franglen
Perfect
- In reply tochrscheuer⬆:JJuan B Caballero @Juan_B_Caballero
Hi! I'm running this script with the Quantize window open and the only parameter that is set is 1/2 grid. All other parameters remain in the same state there were before running the script.
Is there any programmed command that allowed me to set quantize in a specific grid value, specific triplet or not triplet mode, specific swing value, etc... ? I found something like this for Set Grid and Nudge parameters.
With quantize, all the scripts I found worked as a toggle parameter so the final setting depended on the initial state of the parameter.
Thaks!!Christian Scheuer @chrscheuer2020-12-11 22:28:46.170Z
Hi Juan B,
I think it's better that you open a new question for the specific use cases you have – it's easier for us to manage which questions need attention that way, so your questions don't get lost in old threads that are already marked as solved.
Commenting on multiple old questions adds more noise than necessary :)- JJuan B Caballero @Juan_B_Caballero
OK, you are right. It happened that I tried the solution that is in this thread and it doesn't work to me, so maybe I'm doing something wrong. Anyway, I made a new question asking for quantize commands or templates.
Christian Scheuer @chrscheuer2020-12-11 23:09:07.255Z
Thank you :)