Render all selected clips (with fade ins and fade outs)
Hey all!
Trying to convert a KM macro that I've got for rendering drum samples, all of which have fade ins and outs. The script currently asks me how many times to repeat the action, but I'd love if it was possible to just select all the clips and have it do them without me having to do any counting!
The current macro (I'll post a shot from KM) does it with keystrokes, but I'm sure there'll be a smarter way to script it that I don't know with SF. I've tested the sf.ui.proTools.clipDoForEachSelectedClip(); code to in isolation to see what happens, but it seems to cycle through the fades as well, rather than the clip including the fade Is there a neat way around this?

- JJack Byrne @Jack_Byrne
I've also just noticed that it doesn't work with multiple tracks at the same time, which I would need. Can Soundflow get the number of selected clips? There's probably a workaround if I do that instead
samuel henriques @samuel_henriques
Hello Jack,
Try this:function getOriginalToolSelection() { // Get original Tools Selection const originalToolSelection = sf.ui.proTools.mainWindow.cursorToolCluster.buttons.filter(btn => btn.title.value == "Smart tool" || btn.title.value == "Trim tool" || btn.title.value == "Selector tool" || btn.title.value.startsWith("Grabber tool") ).filter(btn => btn.value.invalidate().value === "Selected") return originalToolSelection }; function setOriginalToolSelection(originalToolSelection) { ///Set Original Tools Selection originalToolSelection.map(selBtn => selBtn.title.value).indexOf("Smart Tool") > 0 ? originalToolSelection.filter(selBtn => selBtn.title.value === "Smart Tool")[0].elementClick() : originalToolSelection[0].elementClick() }; function setGrabberTool() { const grabberToolToolBtn = sf.ui.proTools.mainWindow.groups.allItems[2].buttons.whoseTitle.startsWith('Grabber tool').first grabberToolToolBtn.elementClick(); grabberToolToolBtn.popupMenuSelect({ isRightClick: true, menuPath: ['Object'] }); }; function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.invalidate(); const selectedTracksH = sf.ui.proTools.selectedTrackHeaders; const originalToolSelection = getOriginalToolSelection() const getOriginalSelectionEnd = sf.ui.proTools.selectionGetInSamples().selectionEnd // Select grabber tool setGrabberTool(); // Dor for each selected track selectedTracksH.map(track => { // Track select & scroll to view track.trackSelect(); track.trackScrollToView(); // Do for each selected clip sf.ui.proTools.clipDoForEachSelectedClip({ action: () => { // Using grabber will select the complete clip including fades, //group + undo will get the currect timeline selection sf.ui.proTools.menuClick({ menuPath: ["Clip", "Group"] }) sf.ui.proTools.menuClick({ menuPath: ["Edit", "Undo Group Clips"] }); // Using grabber will select the next clip after initial selection, // checking its start to prevent selection const getCurrentSelectionStart = sf.ui.proTools.selectionGetInSamples().selectionStart; if (getCurrentSelectionStart > getOriginalSelectionEnd) return; // Clip consolidate sf.ui.proTools.clipConsolidate(); }, }); }); // Set original Tool Selection and Track Selection setOriginalToolSelection(originalToolSelection); sf.ui.proTools.trackSelectByName({ names: selectedTracksH.map(n => n.normalizedTrackName) }); }; main();
- JIn reply toJack_Byrne⬆:Jack Byrne @Jack_Byrne
That seems to work on a quick test, thanks! It's slower than being able to do it to multiple tracks at the same time, but it also seems to be completely hands off and doesn't require any counting on my part, so at least it means I can just step away and get something else done
samuel henriques @samuel_henriques
Good to hear its working so far. Keep testing and let me know how it goes.
- JJack Byrne @Jack_Byrne
Hey!
So, discovered an issue, if I'm working with two sets of samples across multiple tracks, it just loops at the end of the first track samples, and it's still dramatically slower than the old method. BUT, I've stumbled across something that I think is an improvement.
@raphaelsepulveda posted this here a while ago Is there a way to tell how many clips exist in a pro tools selection? #post-6
let selectedClips = sf.ui.proTools.mainWindow.tables.whoseTitle.is('CLIPS').first.children.whoseRole.is("AXRow").allItems.map(row => row.children[1].children.first.value.value).filter(c => c.startsWith('Selected. ')); log(selectedClips.length);
Which I've tested, and will give a count of the selected number of clips, even if they've got fades (which was a worry). So, all I would need to do is get that value for one track worth of the multi-mic sample, then use that to know how many times to repeat the OG keyboard maestro loop.
The next step after this is going to potentially be some real fun automation around running that loop, then exporting to the right folder and pulling those into Name Mangler to run my reverse sequencing loop so that they'll drop into Trigger Instrument Editor in the right order, but I've got some research to do before I can figure that out because I'm a code moron