Hi! Im trying to make a script that would load a plugin in the next avaible insert, but I need the same script to work on HDX systems and non HDX (my laptop).
I know how to make it work in either configuration with the trackInsertOrSendSelect function but I haven't figured out a condition that would let me choose either path in the code, either it's ['multichannel plug-in', 'Effect', 'CLA Effects (stereo)'] or ['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)']
thank you for the help!
Linked from:
- Christian Scheuer @chrscheuer2020-03-20 08:18:51.070Z
Hi @MixedByRQ.
We've been working on an easier way to do this in the upcoming release of 3.5.
In other words, once 3.5 is updated, this will require less code.Until we get 3.5 released, you can find some info here:
https://forum.soundflow.org/-744#post-22And you can also take a look in this script for an approach:
sf.ui.proTools.appActivateMainWindow(); function getFirstFreeInsertIndex() { var btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons; let insertArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; for (let i = 0; i < insertArray.length; i++) if (btns[insertArray[i]].value.invalidate().value === "unassigned") return (insertArray[i]); throw 0; } function clickPopupMenu(popupMenu, paths) { for (var i = 0; i < paths.length; i++) { var path = paths[i]; if (popupMenu.menuClickPopupMenu({ menuPath: path, onError: 'Continue' }).success) { return; } } throw "None of the provided paths were present in this popup menu"; } function addCLAEffects() { var popupMenu = sf.ui.proTools.selectedTrack.trackInsertOrSendOpenMenu({ insertOrSend: 'Insert', pluginNumber: getFirstFreeInsertIndex() + 1, }).popupMenu; clickPopupMenu(popupMenu, [ ['multichannel plug-in', 'Effect', 'CLA Effects (stereo)'], ['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)'], ]); } addCLAEffects();
- In reply tochrscheuer⬆:MMixedByRQ @MixedByRQ
Thank you for the help! I've made a couple modifications that add support for mono/stereo or stereo instances of plugins
function getFirstFreeInsertIndex() { var btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons; for (var i = 0; i < 10; i++) if (btns[i].value.invalidate().value === "unassigned") return i; return -1; } var pluginPaths = [['plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel plug-in', 'Effect', 'CLA Effects (stereo)'], ['Native plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)'] ] function clickPopupMenu(popupMenu, paths) { for (var i = 0; i < paths.length; i++) { var path = paths[i]; if (popupMenu.menuClickPopupMenu({ menuPath: path, onError: 'Continue' }).success) { return; } } throw "None of the provided paths were present in this popup menu"; } function addPlugin() { var popupMenu = sf.ui.proTools.selectedTrack.trackInsertOrSendOpenMenu({ insertOrSend: 'Insert', pluginNumber: getFirstFreeInsertIndex() + 1, }).popupMenu; clickPopupMenu(popupMenu, pluginPaths); } addPlugin();
Christian Scheuer @chrscheuer2020-03-20 09:42:33.763Z
Hi - thanks for the feedback.
For quoting code, insert a line before and after your code that consists of three backticks:
```
I'll edit your post to include this.
- In reply tochrscheuer⬆:MMixedByRQ @MixedByRQ
Sorry for the mess I'm new to Soundflow and I don't know how to make the code look nice in comments lol
Christian Scheuer @chrscheuer2020-03-20 09:44:04.652Z
All good :) See my other comment on how to do the formatting.
Welcome to SoundFlow!
- In reply toMixedByRQ⬆:Jonathan Roye @Jonathan_Roye
Currently trying to crack the code on this as well. Did you ever get this working? Appreciate any help!
- MMixedByRQ @MixedByRQ
function getFirstFreeInsertIndex() { var btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons; for (var i = 0; i < 10; i++) if (btns[i].value.invalidate().value === "unassigned") return i; return -1; } var pluginPaths = [['plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel plug-in', 'Effect', 'CLA Effects (stereo)'], ['Native plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)'] ] function clickPopupMenu(popupMenu, paths) { for (var i = 0; i < paths.length; i++) { var path = paths[i]; if (popupMenu.menuClickPopupMenu({ menuPath: path, onError: 'Continue' }).success) { return; } } throw "None of the provided paths were present in this popup menu"; } function addPlugin() { var popupMenu = sf.ui.proTools.selectedTrack.trackInsertOrSendOpenMenu({ insertOrSend: 'Insert', pluginNumber: getFirstFreeInsertIndex() + 1, }).popupMenu; clickPopupMenu(popupMenu, pluginPaths); } try{ addPlugin(); } catch(err){ sf.ui.proTools.menuClick({ menuPath: ["View","Edit Window Views","Inserts F-J"], }); addPlugin(); }
Christian Scheuer @chrscheuer2020-10-30 13:16:18.292Z
Jonathan, if I remember correctly, your issue was that you're on a DSP system right? Can you show us how your menus look - like a screenshot of the popup menu you get when adding an insert?
Jonathan Roye @Jonathan_Roye
For sure - Here is a screen shot of the plugin menus. Going to try the above script as well when I have time to dive into it this weekend. Appreciate the help all. Loving Soundflow thus far.
Jonathan Roye @Jonathan_Roye
And another for multi mono...
Christian Scheuer @chrscheuer2020-10-30 17:29:26.549Z
Thanks! Try this - the pluginPaths property just needs to specify the menu paths in order of priority - I changed these to map to your screenshots now:
function getFirstFreeInsertIndex() { var btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons; for (var i = 0; i < 10; i++) if (btns[i].value.invalidate().value === "unassigned") return i; return -1; } var pluginPaths = [['DSP plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel DSP plug-in', 'Effect', 'CLA Effects (stereo)'], ['Native plug-in', 'Effect', 'CLA Effects (mono/stereo)'], ['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)'] ] function clickPopupMenu(popupMenu, paths) { for (var i = 0; i < paths.length; i++) { var path = paths[i]; if (popupMenu.menuClickPopupMenu({ menuPath: path, onError: 'Continue' }).success) { return; } } throw "None of the provided paths were present in this popup menu"; } function addPlugin() { var popupMenu = sf.ui.proTools.selectedTrack.trackInsertOrSendOpenMenu({ insertOrSend: 'Insert', pluginNumber: getFirstFreeInsertIndex() + 1, }).popupMenu; clickPopupMenu(popupMenu, pluginPaths); } try{ addPlugin(); } catch(err){ sf.ui.proTools.menuClick({ menuPath: ["View","Edit Window Views","Inserts F-J"], }); addPlugin(); }
Jonathan Roye @Jonathan_Roye
Brilliant! Looking like this script is working. Just because I'm dumb...All I would need to do is for each plugin I want is to Change the category and plugin name here?
var pluginPaths = [['DSP plug-in', 'Effect', 'CLA Effects (mono/stereo)'],
['multichannel DSP plug-in', 'Effect', 'CLA Effects (stereo)'],
['Native plug-in', 'Effect', 'CLA Effects (mono/stereo)'],
['multichannel Native plug-in', 'Effect', 'CLA Effects (stereo)']
]Christian Scheuer @chrscheuer2020-10-30 22:01:06.259Z
Yes, exactly :) It just needs to match what the menu item would be called.
- In reply toJonathan_Roye⬆:MMixedByRQ @MixedByRQ
Thats what I have!! It's been working fine for me let me know if it helps!