Pro Tools - Set nudge value regardless wether in Edit or MIDI Editor
By T Francis @T_Francis
Hi guys, so I've got this script (not mine, it was taken from another forum page) which is a brilliant way of setting the Grid value for either the Edit or MIDI Editor depending on which window is focussed. Is there a way to adapt this to do the same for Nudge Value? I did try adapting it by substituting Grid for Nudge but without success!
selectGrid({
//targetNoteValue: '1 bar', targetNoteType: 'Standard'
//targetNoteValue: '1/2 note', targetNoteType: 'Standard'
//targetNoteValue: '1/4 note', targetNoteType: 'Standard'
//targetNoteValue: '1/8 note', targetNoteType: 'Standard'
//targetNoteValue: '1/16 note', targetNoteType: 'Standard'
//targetNoteValue: '1/32 note', targetNoteType: 'Standard'
//targetNoteValue: '1/64 note', targetNoteType: 'Standard'
//targetNoteValue: '1/2 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/4 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/8 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/16 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/32 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/64 note', targetNoteType: 'Dotted'
//targetNoteValue: '1/2 note', targetNoteType: 'Triplet'
//targetNoteValue: '1/4 note', targetNoteType: 'Triplet'
//targetNoteValue: '1/8 note', targetNoteType: 'Triplet'
//targetNoteValue: '1/16 note', targetNoteType: 'Triplet'
//targetNoteValue: '1/32 note', targetNoteType: 'Triplet'
//targetNoteValue: '1/64 note', targetNoteType: 'Triplet'
});
function selectGrid({ targetNoteValue, targetNoteType }) {
//Check to see if the "Edit:" or "MIDI Editor" windows are in focus
if (sf.ui.proTools.focusedWindow.title.value.indexOf('Edit: ') === 0) {
var gridButton = sf.ui.proTools.windows.whoseTitle.startsWith('Edit:').first.groups.whoseTitle.is('Grid/Nudge Cluster').first.popupButtons.whoseTitle.is('Grid Value').first;
} else if (sf.ui.proTools.focusedWindow.title.value.indexOf('MIDI Editor:') === 0) {
var gridButton = sf.ui.proTools.windows.whoseTitle.startsWith('MIDI Editor:').first.groups.whoseTitle.is('Grid/Nudge View').first.textFields.whoseTitle.is('Grid Value').first;
} else {
throw ('Grid popup menu not available');
};
//Check that Grid mode is set to Bars|Beats
if (gridButton.value.invalidate().value.indexOf("|") < 0) {
gridButton.popupMenuSelect({ menuPath: ['Bars|Beats'] });
sf.wait({intervalMs:150});
};
//Get Grid display value as a variable
const currentGridDisplay = gridButton.value.invalidate().value.replace(/\s/g, '');
//Displayed grid value lookup array
var gridDisplayLookup = [
{ displayedValue: '1|0|000', noteValue: '1 bar', noteType: 'Standard' },
{ displayedValue: '0|2|000', noteValue: '1/2 note', noteType: 'Standard' },
{ displayedValue: '0|1|000', noteValue: '1/4 note', noteType: 'Standard' },
{ displayedValue: '0|0|480', noteValue: '1/8 note', noteType: 'Standard' },
{ displayedValue: '0|0|240', noteValue: '1/16 note', noteType: 'Standard' },
{ displayedValue: '0|0|120', noteValue: '1/32 note', noteType: 'Standard' },
{ displayedValue: '0|0|060', noteValue: '1/64 note', noteType: 'Standard' },
{ displayedValue: '0|3|000', noteValue: '1/2 note', noteType: 'Dotted' },
{ displayedValue: '0|1|480', noteValue: '1/4 note', noteType: 'Dotted' },
{ displayedValue: '0|0|720', noteValue: '1/8 note', noteType: 'Dotted' },
{ displayedValue: '0|0|360', noteValue: '1/16 note', noteType: 'Dotted' },
{ displayedValue: '0|0|180', noteValue: '1/32 note', noteType: 'Dotted' },
{ displayedValue: '0|0|090', noteValue: '1/64 note', noteType: 'Dotted' },
{ displayedValue: '0|1|320', noteValue: '1/2 note', noteType: 'Triplet' },
{ displayedValue: '0|0|640', noteValue: '1/4 note', noteType: 'Triplet' },
{ displayedValue: '0|0|320', noteValue: '1/8 note', noteType: 'Triplet' },
{ displayedValue: '0|0|160', noteValue: '1/16 note', noteType: 'Triplet' },
{ displayedValue: '0|0|080', noteValue: '1/32 note', noteType: 'Triplet' },
{ displayedValue: '0|0|040', noteValue: '1/64 note', noteType: 'Triplet' },
];
//Assign Grid Value and Type from lookup
var gridNoteValue = gridDisplayLookup.filter(o => o.displayedValue === currentGridDisplay)[0].noteValue;
var gridNoteType = gridDisplayLookup.filter(o => o.displayedValue === currentGridDisplay)[0].noteType;
//Set note length
if (targetNoteValue !== gridNoteValue) {
gridButton.popupMenuSelect({ menuPath: [targetNoteValue] });
};
//Toggle Triplet
function toggleTriplet() {
gridButton.popupMenuSelect({ menuPath: ['triplet'] });
}
//Toggle Dotted
function toggleDotted() {
gridButton.popupMenuSelect({ menuPath: ['dotted'] });
}
//Decifer what to toggle to change to the correct target note type
if (targetNoteType !== gridNoteType && targetNoteValue !== '1 bar') {
if (targetNoteType === 'Triplet' && gridNoteType === 'Standard') { toggleTriplet(); };
if (targetNoteType === 'Triplet' && gridNoteType === 'Dotted') { toggleTriplet(); };
if (targetNoteType === 'Dotted' && gridNoteType === 'Standard') { toggleDotted(); };
if (targetNoteType === 'Dotted' && gridNoteType === 'Triplet') { toggleDotted(); };
if (targetNoteType === 'Standard' && gridNoteType === 'Triplet') { toggleTriplet(); };
if (targetNoteType === 'Standard' && gridNoteType === 'Dotted') { toggleDotted(); };
};
}
Thanks for your help as always!
Trystan