Hello.
I'm trying to make useful plugin loader.
I've gotten a lot of help with questions in the past.
I have since made updates and now have the following design, which is working very well.
My hope is that as an additional feature, when I try to insert a new plugin into a slot that has already been inserted slot, it will be alerted and can choose OK or Cancel.
Is such a thing feasible?
And a very large script, so I'd like to get some ideas on how to make it smaller.
Best regards.
1st window (select slot)

ex. "Slot A"
globalState.insertSlot = 1
//to plugin select deck
sf.decks.get('user:ckmmgyrb800005e109czblt0g:ckmp18gyp0002l310n1aytbqp').showOnStreamDeck({
device: sf.devices.streamDeck.getDeviceByContext('241C0D50FDB0C78F56C6497C4F4A5D83'),
});
ex. "Next Free Slot"
globalState.insertSlot = undefined
//to plugin select deck
sf.decks.get('user:ckmmgyrb800005e109czblt0g:ckmp18gyp0002l310n1aytbqp').showOnStreamDeck({
device: sf.devices.streamDeck.getDeviceByContext('241C0D50FDB0C78F56C6497C4F4A5D83'),
});
next window (plugin select)

script
//focus protools
sf.ui.proTools.appActivate();
//memory original window
let originalWin = sf.ui.proTools.focusedWindow.title.value.split(":").slice(0, 1).join(":")
//show edit window
sf.ui.proTools.menuClick({ menuPath: ["Window", "Edit"] });
//scroll to selected track
sf.ui.proTools.selectedTrack.trackScrollToView();
sf.ui.proTools.selectedTrack.titleButton.mouseClickElement({
isControl: true,
isShift: true,
});
//Close plug-in windows
sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in').allItems.forEach(function (win) {
try { win.windowClose(); } catch (err) { }
});
//Insert plugin
//If globalstate is undefine, insert the next free slot.
if (globalState.insertSlot == undefined) {
var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames.slice();
for (var name of originallySelectedTrackNames) {
sf.ui.proTools.trackSelectByName({
names: [name],
});
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;
}
sf.ui.proTools.selectedTrack.trackInsertOrSendSelect({
insertOrSend: "Insert",
pluginNumber: getFirstFreeInsertIndex() + 1,
pluginSelector: items => items.filter(item => item.path[0].indexOf("Native plug-in") >= 0 && item.path.slice(-1)[0].indexOf("EQ3 7-Band") === 0)[0],
});
}
sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames });
//globalstate assigned
} else {
var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames.slice();
for (var name of originallySelectedTrackNames) {
sf.ui.proTools.trackSelectByName({
names: [name],
});
sf.ui.proTools.selectedTrack.trackInsertOrSendSelect({
insertOrSend: "Insert",
pluginNumber: Number(globalState.insertSlot),
pluginSelector: items => items.filter(item => item.path[0].indexOf("Native plug-in") >= 0 && item.path.slice(-1)[0].indexOf("EQ3 7-Band") === 0)[0],
});
}
sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames });
//reset globalstate
globalState.insertSlot = undefined
}
//show original window
sf.ui.proTools.menuClick({ menuPath: ["Window", originalWin] });
//go back to deck for selecting slot
sf.decks.get('user:ckmmgyrb800005e109czblt0g:ckmp19gyz0003l310679bo7r2').showOnStreamDeck({
device: sf.devices.streamDeck.getDeviceByContext('241C0D50FDB0C78F56C6497C4F4A5D83'),
});
- Christian Scheuer @chrscheuer2021-04-02 21:46:55.616Z
Hi Yujiro,
Have you seen this package?
https://soundflow.org/store/teezios-plugin-loader
It already makes sure to add plugins to the next available slot :)
Yujiro Yonetsu @Yujiro_Yonetsu
Thank you very much.
I know it.That script is very nice, but
I think it more convenient to select the slot each time and do the insert.
That's why I have my script.Thanks to @samuel_henriques , I can now use globalstate to flexibly select slots.
I can also assign it to the next free slot.From the current situation, I think it would be perfect if I could get an alert when I have specified an override for an insert.
What do you think?
samuel henriques @samuel_henriques
hey @Yujiro_Yonetsu,
I'm thinking you could change the code where you assign the inserts slots to this. It will alert you if a plug-in is in the selected slot. It won't anything about it, only an alert. If you select a plugin the slot will be overwritten.
This would work for insert 1const slotNumber = 1 globalState.insertSlot = slotNumber const insertAssignment = sf.ui.proTools.selectedTrack.invalidate().insertButtons[slotNumber - 1].value.invalidate().value; if (insertAssignment != "unassigned"){ alert(`Selected slot has ${insertAssignment}.\n\nSelecting a new plug-in, will override\n${insertAssignment}.`) }
Yujiro Yonetsu @Yujiro_Yonetsu
This is the perfect solution!
Thank you @samuel_henriques !I'll also try various ways to log this dialog.
I will try to make this a log display instead of a dialog, and so on.In the meantime, this is very easy to use at the moment.
Thank you!