Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 06-12-2014, 02:29 PM   #1
David Perry
Human being with feelings
 
Join Date: Oct 2010
Posts: 272
Default A script to float a specific plug-in GUI from a selected track?

Hi guys,

I'm wondering if it would be hard for someone to put together a new script that would allow a single shortcut key to float a pre-defined plug-in GUI once a track is selected. I want to use this to float my main EQ instantly on any track without having to right click and wait for the FX dropdown, which can be slow.

Someone did a short script that allows you to write a plug-in name into the script and you execute this action to load it into the chain of a selected track.

I can post that script (but I wasn't sure if it was kosher since I didn't write it and I don't remember who did) if it would be helpful (i.e. if it might be adaptable to this GUI floating idea).

I'm aware that there is an SWS action to float a GUI based on order but I would rather have one based on name so the action will work regardless of what order the plug-in appears on the track.

Thanks much in advance to anyone willing to help out.

Dave
David Perry is offline   Reply With Quote
Old 06-12-2014, 03:06 PM   #2
pakkuncung
Human being with feelings
 
pakkuncung's Avatar
 
Join Date: Sep 2012
Location: Indonesia
Posts: 91
Default

For my workflow—instead of opening each plugin to tweak, EQing is easier and also faster by showing EQ parameters on MCP. It's more similar to twisting knobs on analog mixing console.

To make it even faster to set-up, the EQ plugin can be saved as FX chains, and pasted to the particular track using SWS action assigned to keyboard shortcut.

Anyway YMMV though, and your requested script might come handy on certain mixing situation.

Someone might help you with the appropriate script. Good luck
__________________
JRENG!
EHX
pakkuncung is offline   Reply With Quote
Old 06-12-2014, 03:48 PM   #3
David Perry
Human being with feelings
 
Join Date: Oct 2010
Posts: 272
Default

I appreciate the suggestions. I already have a single action to put the EQ on the track based on the script I mentioned in the first post.

I use a very versatile EQ called DMG EQuick which cannot be used effectively without the GUI. Putting some knobs on the TCP would be much, much slower than opening and using the GUI directly, since EQuick is designed very carefully to be very efficient with its interface, and there are far too many parameters to narrow down to a few panel knobs. I also always have the analyzer showing on the GUI, which I often use.
David Perry is offline   Reply With Quote
Old 11-03-2014, 04:25 PM   #4
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

so is there no way to float specific plugins by name?

if not then i think that's a good case for implementing fixed plugin slots.

that way we can continue to select plugins by position like now, except they also won't move around when adding/removing fx.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 11-03-2014, 04:29 PM   #5
technogremlin
Human being with feelings
 
technogremlin's Avatar
 
Join Date: Mar 2008
Location: Netherlands
Posts: 2,629
Default

I could use this. I'm using ReaEQ on each channel with it's controls hidden, controlling it from the channel-strip mode on my Tascam US-2400. I use the plugin-window for the analyser function when doing surgical EQ.

If you can get met the example code you mentioned, I might have a stab at it
technogremlin is offline   Reply With Quote
Old 11-04-2014, 04:02 AM   #6
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Code:
from reaper_python import *

def ShowNamedPlugin(sPluginName, pTrack, create) :
	'''
	If named plugin not found and create is True, add it to track FX chain
	If track FX chain is hidden, float the plugin.
	If track FX chain is open, switch focus to the plugin if it isn't selected
	'''
	iPlugin =  RPR_TrackFX_GetByName(pTrack, sPluginName, create)
	if iPlugin > -1 :
		iSel = RPR_TrackFX_GetChainVisible(pTrack)

		if iSel == -1 : # FX chain hidden
			if RPR_TrackFX_GetOpen(pTrack, iPlugin) :
				RPR_TrackFX_Show(pTrack, iPlugin, 2) # 0 == hidechain, 1 == showchain, 2 == hide floating window, 3 == show floating window
			else :
				RPR_TrackFX_Show(pTrack, iPlugin, 3) # 0 == hidechain, 1 == showchain, 2 == hide floating window, 3 == show floating window
				
		elif iSel == -2 : # FX chain visible but no effect selected
			RPR_TrackFX_Show(pTrack, iPlugin, 1) # 0 == hidechain, 1 == showchain, 2 == hide floating window, 3 == show floating window
			
		else : # FX chain is visible
			
			if iSel != iPlugin :
				# Plugin is not selected, switch to and enable
				RPR_TrackFX_Show(pTrack, iPlugin, 1) # 0 == hidechain, 1 == showchain, 2 == hide floating window, 3 == show floating window
				
sPluginName = "ReaEQ"
pProject = 0

# Show named plugin if it exists on any selected track
for i in range(RPR_CountSelectedTracks(pProject)) :
	pTrack = RPR_GetSelectedTrack(pProject, i)
	ShowNamedPlugin(sPluginName, pTrack, False)

Last edited by IXix; 11-04-2014 at 04:08 AM.
IXix is offline   Reply With Quote
Old 11-04-2014, 08:35 AM   #7
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

eel-ized

Code:
//by IXix (translated by Elan Hickler, edited by spk77)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "SPAN";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 11-08-2014 at 04:50 PM.
Argitoth is offline   Reply With Quote
Old 11-04-2014, 12:38 PM   #8
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

wow fun. never tried running a script before but that should be quite helpful if i can get it working.

btw guys, ya'll know there is a built in action to insert/view ReaQ right? but this looks like we can plug in any plugin name and it should work similarly.

EDIT: ok so that was pretty painless. didnt know running scripts was such a snap. but what if your plugin is on the master track? it doesnt work then. also says it will add the fx if its not there already, which it didnt, but it floats the gui if present.
__________________
foxyyymusic

Last edited by foxAsteria; 11-04-2014 at 01:00 PM.
foxAsteria is online now   Reply With Quote
Old 11-04-2014, 01:38 PM   #9
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by PooFox View Post
but what if your plugin is on the master track? it doesnt work then.
Yeah, the master track is different. You can still get a pointer to it though and it will behave the same. You just have to use RPR_GetMasterTrack. I made a helper so I can just remember one function.
Code:
def GetTrack(pProject, iIndex) :
	if iIndex < 0 :
		return RPR_GetMasterTrack(pProject)
	else :
		return RPR_GetTrack(pProject, iIndex)
I'm not sure how you would tell if the master track was in the selected tracks though.
Quote:
Originally Posted by PooFox View Post
also says it will add the fx if its not there already, which it didnt, but it floats the gui if present.
If you want to create the plugin when it's not present, you do this instead...
Code:
ShowNamedPlugin(sPluginName, pTrack, True)
IXix is offline   Reply With Quote
Old 11-08-2014, 08:20 AM   #10
EricBismarck
Human being with feelings
 
Join Date: Jun 2014
Posts: 22
Default

This is exactly what I need - thanks!

I want to assign buttons on my BCR2000 to specific FX, so hitting the button brings up the right FX.

This will do it (I think!)

Thanks,

Eric
EricBismarck is offline   Reply With Quote
Old 11-08-2014, 01:34 PM   #11
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

yea thanks alot IXix. still havent had time to get into the nitty gritty of the code language, but it's a very helpful script. although i cant seem to get the plugin to generate when not present and not sure where to add that master track section.

Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "SPAN";
pProject = 0;

loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, True);
);
thats what i have now but changing that last line to true didnt seem to change any behavior. plugin alias "SPAN" is also identical to the dll name if that's any concern. anyways, thanks for your help, soon ill start writing my own!
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 11-08-2014, 01:49 PM   #12
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

check the python version. my eel version is untested,

OHHH oops... that's because "True" is always 0. I'll change the code.

Edit: Oh wait, no, my original code is correct. I don't use True or False, I use 1 and 0.

Edit: You could add this to the top of the code
Code:
True = 1;
//False is automatically 0 because False was never assigned to a value.
btw eel is not case sensitive last time I checked
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 11-08-2014, 02:26 PM   #13
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Quote:
Originally Posted by Argitoth View Post
Edit: You could add this to the top of the code
[code]
True = 1;
thanks dude, that did the trick! just cant get it to work with the master track yet.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 11-08-2014, 02:36 PM   #14
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Ah, didn't realise you were using the EEL version. As Argitoth has noted there are no 'True' and 'False' constants in EEL so you need to use 1 or 0 for those in converted scripts. If you just want to open/create an instance of SPAN on the master you'd do this...
Code:
ShowNamedPlugin("SPAN", GetMasterTrack(0), 1);
IXix is offline   Reply With Quote
Old 11-08-2014, 03:00 PM   #15
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Quote:
Originally Posted by IXix View Post
Ah, didn't realise you were using the EEL version
sorry for my confusion. eel seemed a bit more straightforward. i just wanted to get the above script compatible when the master track happens to be selected. almost there.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 11-08-2014, 03:19 PM   #16
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by PooFox View Post
sorry for my confusion. eel seemed a bit more straightforward. i just wanted to get the above script compatible when the master track happens to be selected. almost there.
This should work for master track also:

Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "SPAN";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);

Last edited by spk77; 11-08-2014 at 03:33 PM.
spk77 is offline   Reply With Quote
Old 11-08-2014, 03:21 PM   #17
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by PooFox View Post
sorry for my confusion. eel seemed a bit more straightforward. i just wanted to get the above script compatible when the master track happens to be selected. almost there.
I can't think how you would detect whether the master is selected. If you figure it out then let me know. I just have a button to open/create span on the master, no selection involved.

edit: spk77 nailed it while I was typing
IXix is offline   Reply With Quote
Old 11-08-2014, 04:46 PM   #18
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

just beautiful guys! works perfectly.

someone should pop that code into the OP since now all bases are covered you can just pop in your vst name and create individual scripts per plug.

awesome. cant wait to start writing my own scripts (after i get a handle on the syntax of course)!
__________________
foxyyymusic

Last edited by foxAsteria; 11-08-2014 at 04:52 PM.
foxAsteria is online now   Reply With Quote
Old 04-09-2015, 05:13 AM   #19
stereolost
Human being with feelings
 
stereolost's Avatar
 
Join Date: Mar 2015
Location: Moscow, Russia
Posts: 206
Default

Great stuff you have here! Two weeks with Reaper and i'm blown by what it can do... combined with it's community, of course.

One thing - is there a way to float fx GUI from the Monitoring FXchain?
stereolost is offline   Reply With Quote
Old 04-09-2015, 05:27 AM   #20
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@stereolost
If I remember well, we can't access monitor FX with script =/
X-Raym is offline   Reply With Quote
Old 04-09-2015, 11:46 AM   #21
rluka
Human being with feelings
 
rluka's Avatar
 
Join Date: Jul 2013
Location: Edmonton, Alberta, Canada
Posts: 258
Default

Just wanted to say Thanks..this script works great
__________________
Ron L, i7 laptop x64, Win7pro/x64(dual boot), 7200rpm hd, 2 ext. hd, Scarlett 2i4, Event 20/20 audio monitors, 1 ext. video monitor, Novation Launch Control XL, REAPER x64, Sonar Platinum
rluka is offline   Reply With Quote
Old 04-09-2015, 01:04 PM   #22
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by X-Raym View Post
If I remember well, we can't access monitor FX with script =/
No, not possible. I've mentioned it a few times in various pre-release cycles when API stuff was on the table but never got a response. Not sure if there's a tracker item for it or not.
IXix is offline   Reply With Quote
Old 08-06-2015, 06:13 AM   #23
buddhajuke
Human being with feelings
 
Join Date: Jun 2012
Posts: 277
Default

Would someone be willing to make an alternate version of this script (small tweak I'm thinking) that works project wide? I typically have one instance of Maschine 2 in my project and would love to hit a button to float it from anywhere, regardless of whether or not the track is selected.

I have tried this with window sets and cycle actions but it messes up project to project. This script is smooth like butter.
buddhajuke is offline   Reply With Quote
Old 08-06-2015, 09:41 AM   #24
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by buddhajuke View Post
Would someone be willing to make an alternate version of this script (small tweak I'm thinking) that works project wide? I typically have one instance of Maschine 2 in my project and would love to hit a button to float it from anywhere, regardless of whether or not the track is selected.

I have tried this with window sets and cycle actions but it messes up project to project. This script is smooth like butter.
Code:
// by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName) local(iSel pTrack iPlugin fx_found i iTrackCount) (
  /*
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  fx_found = 0;
  // Check master track first
  pTrack = GetMasterTrack();
  iPlugin = TrackFX_GetByName(pTrack, sPluginName, 0);
  iPlugin > -1 ? fx_found = 1;

  // FX not on master track -> check other tracks
  iTrackCount = CountTracks(0);
  i = 0;
  while(!fx_found && i < iTrackCount - 1) (
    pTrack = GetTrack(0, i);
    iPlugin = TrackFX_GetByName(pTrack, sPluginName, 0);
    iPlugin > -1 ? fx_found = 1;
    i = i+1;
  );
  
  // FX found
  fx_found ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 0):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);

sPluginName = "Maschine 2"; // Edit this if it doesn't work
   
ShowNamedPlugin(sPluginName);

Last edited by spk77; 08-06-2015 at 09:50 AM. Reason: better variable names
spk77 is offline   Reply With Quote
Old 08-06-2015, 09:46 AM   #25
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by buddhajuke View Post
Would someone be willing to make an alternate version of this script (small tweak I'm thinking) that works project wide? I typically have one instance of Maschine 2 in my project and would love to hit a button to float it from anywhere, regardless of whether or not the track is selected.

I have tried this with window sets and cycle actions but it messes up project to project. This script is smooth like butter.
This should do it, two scripts to open next/prev instance of named plugin in the project.

Just change this bit at the top of the two "Focus" scripts...
Code:
targetName = "VST: ReaEQ (Cockos)";
The name has to be exactly as shown in the fx chain, so if you rename your Maschine instance to "FluffyWuffy" you'd have to do this...
Code:
targetName = "FluffyWuffy";
If the plugin isn't found it pops up a message.

edit: How does spk77 know to post a solution while I'm typing?
Attached Files
File Type: zip OpenInstance.eel.zip (2.4 KB, 175 views)

Last edited by IXix; 08-06-2015 at 01:35 PM.
IXix is offline   Reply With Quote
Old 08-06-2015, 06:04 PM   #26
buddhajuke
Human being with feelings
 
Join Date: Jun 2012
Posts: 277
Default

Thank you
buddhajuke is offline   Reply With Quote
Old 01-13-2020, 06:34 AM   #27
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

I know this is an old thread, but I'm hoping someone can help... I've been using this script to float plugins by name and it works brilliantly, but I don't know how to make it ADD the plugin if it doesn't already exist on the track. I can see from the text at the top of the script that if 'create is true' it will do that... but I have know idea how to make that happen.

I see there are a few different versions here, so here is the specific code I'm using -

Code:
function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "Main EQ";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
I'd appreciate it if someone could point me in the right direction.

Thanks.
Joe90 is offline   Reply With Quote
Old 01-13-2020, 10:03 AM   #28
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

I make little scripts for each plugin I want to handle. This is the one for the SPAN on my monitor FX (see newer version below)...
Code:
@import Include/ShowNamedPlugin.func.eel

Undo_BeginBlock2(0);

ShowNamedPlugin("SPAN", GetMasterTrack(0), 1, 1, 1);
        
 Undo_EndBlock2(0, "Toggle SPAN visible", 2);
ShowNamedPlugin is in its own file that I import. You can of course just include the whole function text in your script but importing means that if you change the function, you only have to change one file instead of twenty. Here's the latest version that can handle the input FX and monitor FX chains too...
Code:
// If bExtFX is > 0 use the record FX chain (monitor FX for master track)
// If named plugin not found and bCreate is > 0, add it to track FX chain
// If track FX chain is hidden, float the plugin.
// If track FX chain is open, switch focus to the plugin if it isn't selected
// If bToggleActive > 0 enable plugin if showing, disable if hiding or toggle if visible in fx chain window
// Returns 1 if plugin is visible, 2 if enabled, 3 if visible and enabled, 0 if not visible or enabled
function ShowNamedPlugin(sPluginName, pTrack, bToggleActive, bCreate, bExtFX)
local(iPlugin, iSel, ret)
(
    ret = 0;
    
    iPlugin = TrackFX_AddByName(pTrack, sPluginName, bExtFX, bCreate);

    iPlugin > -1 ?
    (
        bExtFX ?
        (
            iPlugin |= 0x1000000;
            iSel = TrackFX_GetRecChainVisible(pTrack);
        )
        :
        (
            iSel = TrackFX_GetChainVisible(pTrack);
        );
        
        iSel == -1 ? // FX chain hidden, show/hide floating FX window
        (
            TrackFX_GetOpen(pTrack, iPlugin) ?
            (
                TrackFX_Show(pTrack, iPlugin, 2);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 0);
                );
            )
            :
            (
                TrackFX_Show(pTrack, iPlugin, 3);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            );
        )        
        : iSel == -2 ? // FX chain visible but no effect selected, select plugin in chain
        (
            TrackFX_Show(pTrack, iPlugin, 1);
            bToggleActive ?
            (
                TrackFX_SetEnabled(pTrack, iPlugin, 1);
            );
        )    
        : // FX chain is visible
        (    
            iSel != iPlugin ? // Plugin isn't selected. Select and enable if necessary.
            (
                 TrackFX_Show(pTrack, iPlugin, 1); // 0 == hidechain, 1 ==  showchain, 2 == hide floating window, 3 == show floating window
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            )
            : // Plugin is selected. Toggle enable if necessary.
            (
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, !TrackFX_GetEnabled(pTrack, iPlugin));
                );
            )
        );
        
        // Construct return value
        TrackFX_GetOpen(pTrack, iPlugin) ? ret = 1;
        TrackFX_GetEnabled(pTrack, iPlugin) ? ret |= 2;
    )
    :
    (
        MB(sprintf(#, "%s not found!", sPluginName), "Plugin not found", 0);
    );
    
    ret;
 );

Most useful script I ever made.
IXix is offline   Reply With Quote
Old 01-13-2020, 12:16 PM   #29
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

Quote:
Originally Posted by IXix View Post
. You can of course just include the whole function text in your script
Sorry - I have very limited knowledge of scripting or coding...

If I were to combine these scripts as you suggested, then where would I add the code from one to the other? I don't need the extra flexibility of separating the plugin name scripts from the main script (although I see why it would be useful) so all I really need is a script that does what the script I posted above does, except it also creates the named FX if it's not present on the track.

If you could walk me through the simplest way to achieve that, I'd be very grateful. If you have an improved version (works with monitor FX etc) that is all wrapped up in one script per plugin, then even better.

Thanks.
Joe90 is offline   Reply With Quote
Old 01-13-2020, 02:05 PM   #30
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Try this. Didn't test it but should be okay.

Code:
// Change this stuff
pluginName = "Some Plugin";
track = GetMasterTrack();
toggleActive = 1; // enable/disable plugin?
create = 1; // create the plugin if it doesn't exist?
extFX = 0; // input fx/monitor fx chain?

// If bExtFX is > 0 use the record FX chain (monitor FX for master track)
// If named plugin not found and bCreate is > 0, add it to track FX chain
// If track FX chain is hidden, float the plugin.
// If track FX chain is open, switch focus to the plugin if it isn't selected
// If bToggleActive > 0 enable plugin if showing, disable if hiding or toggle if visible in fx chain window
// Returns 1 if plugin is visible, 2 if enabled, 3 if visible and enabled, 0 if not visible or enabled
function ShowNamedPlugin(sPluginName, pTrack, bToggleActive, bCreate, bExtFX)
local(iPlugin, iSel, ret)
(
    ret = 0;
    
    iPlugin = TrackFX_AddByName(pTrack, sPluginName, bExtFX, bCreate);

    iPlugin > -1 ?
    (
        bExtFX ?
        (
            iPlugin |= 0x1000000;
            iSel = TrackFX_GetRecChainVisible(pTrack);
        )
        :
        (
            iSel = TrackFX_GetChainVisible(pTrack);
        );
        
        iSel == -1 ? // FX chain hidden, show/hide floating FX window
        (
            TrackFX_GetOpen(pTrack, iPlugin) ?
            (
                TrackFX_Show(pTrack, iPlugin, 2);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 0);
                );
            )
            :
            (
                TrackFX_Show(pTrack, iPlugin, 3);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            );
        )        
        : iSel == -2 ? // FX chain visible but no effect selected, select plugin in chain
        (
            TrackFX_Show(pTrack, iPlugin, 1);
            bToggleActive ?
            (
                TrackFX_SetEnabled(pTrack, iPlugin, 1);
            );
        )    
        : // FX chain is visible
        (    
            iSel != iPlugin ? // Plugin isn't selected. Select and enable if necessary.
            (
                 TrackFX_Show(pTrack, iPlugin, 1); // 0 == hidechain, 1 ==  showchain, 2 == hide floating window, 3 == show floating window
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            )
            : // Plugin is selected. Toggle enable if necessary.
            (
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, !TrackFX_GetEnabled(pTrack, iPlugin));
                );
            )
        );
        
        // Construct return value
        TrackFX_GetOpen(pTrack, iPlugin) ? ret = 1;
        TrackFX_GetEnabled(pTrack, iPlugin) ? ret |= 2;
    )
    :
    (
        MB(sprintf(#, "%s not found!", sPluginName), "Plugin not found", 0);
    );
    
    ret;
);

Undo_BeginBlock2(0);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(pluginName, track, toggleActive, create, extFX);
Undo_EndBlock2(0, sprintf(#, "Toggle %s visible", pluginName), 2);
IXix is offline   Reply With Quote
Old 01-13-2020, 02:57 PM   #31
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

Thank you! Will test it tonight.
Joe90 is offline   Reply With Quote
Old 01-13-2020, 03:19 PM   #32
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

No joy I'm afraid!

I assume the plugin name goes here at the start, replacing "Some Plugin"? -

// Change this stuff
pluginName = "Some Plugin";

That's what I've done, tried with a few different plugin names, checked everything is spelled correctly, but nothing. It doesn't throw up an error or do anything weird, it just does nothing.
Joe90 is offline   Reply With Quote
Old 01-14-2020, 02:04 PM   #33
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

It should give a message if it can't find the plugin. I just tested here and it works fine with this...
Code:
pluginName = "ReaEQ (Cockos)";
IXix is offline   Reply With Quote
Old 01-16-2020, 01:03 PM   #34
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

IXix - hey I've been using your script for years, so thanks again!

It's this:
Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "EQ";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 0);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
It's not broken or anything, but which is the best version to use? Might as well update if you've improved it since...
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 01-16-2020, 02:50 PM   #35
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by foxAsteria View Post
IXix - hey I've been using your script for years, so thanks again!
...
It's not broken or anything, but which is the best version to use? Might as well update if you've improved it since...
You're welcome! The version a couple of posts above is what I'm using now... https://forum.cockos.com/showpost.ph...6&postcount=28
The number of arguments changed though, so it will probably break any scripts that use it. You'd just need to add zeros for the new arguments bToggleActive and bExtFX.
Code:
// old
function ShowNamedPlugin(sPluginName, pTrack, create)

// new
function ShowNamedPlugin(sPluginName, pTrack, bToggleActive, bCreate, bExtFX)
IXix is offline   Reply With Quote
Old 01-19-2020, 07:35 PM   #36
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

Hi IXix - I'm sorry, but I'm still having no luck with this - I've even tested on a fresh portable install and no luck.

The version Fox posted above will float/unfloat a plugin by name for me, but it still doesn't create it. The one you posted doesn't do anything, even throw up an error. I don't script but I've copied/pasted various lua and eel scripts I've found on the forum and it always works, so I'm not sure what's wrong.

Any possible idea?

Just for boring clarification - here is the exact code (copied from your post above) that I'm using. I'm testing with ReaEQ for now, but have tried with other plugins too.

Code:
// Change this stuff
pluginName = "ReaEQ (Cockos)";
track = GetMasterTrack();
toggleActive = 1; // enable/disable plugin?
create = 1; // create the plugin if it doesn't exist?
extFX = 0; // input fx/monitor fx chain?

// If bExtFX is > 0 use the record FX chain (monitor FX for master track)
// If named plugin not found and bCreate is > 0, add it to track FX chain
// If track FX chain is hidden, float the plugin.
// If track FX chain is open, switch focus to the plugin if it isn't selected
// If bToggleActive > 0 enable plugin if showing, disable if hiding or toggle if visible in fx chain window
// Returns 1 if plugin is visible, 2 if enabled, 3 if visible and enabled, 0 if not visible or enabled
function ShowNamedPlugin(sPluginName, pTrack, bToggleActive, bCreate, bExtFX)
local(iPlugin, iSel, ret)
(
    ret = 0;
    
    iPlugin = TrackFX_AddByName(pTrack, sPluginName, bExtFX, bCreate);

    iPlugin > -1 ?
    (
        bExtFX ?
        (
            iPlugin |= 0x1000000;
            iSel = TrackFX_GetRecChainVisible(pTrack);
        )
        :
        (
            iSel = TrackFX_GetChainVisible(pTrack);
        );
        
        iSel == -1 ? // FX chain hidden, show/hide floating FX window
        (
            TrackFX_GetOpen(pTrack, iPlugin) ?
            (
                TrackFX_Show(pTrack, iPlugin, 2);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 0);
                );
            )
            :
            (
                TrackFX_Show(pTrack, iPlugin, 3);
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            );
        )        
        : iSel == -2 ? // FX chain visible but no effect selected, select plugin in chain
        (
            TrackFX_Show(pTrack, iPlugin, 1);
            bToggleActive ?
            (
                TrackFX_SetEnabled(pTrack, iPlugin, 1);
            );
        )    
        : // FX chain is visible
        (    
            iSel != iPlugin ? // Plugin isn't selected. Select and enable if necessary.
            (
                 TrackFX_Show(pTrack, iPlugin, 1); // 0 == hidechain, 1 ==  showchain, 2 == hide floating window, 3 == show floating window
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, 1);
                );
            )
            : // Plugin is selected. Toggle enable if necessary.
            (
                bToggleActive ?
                (
                    TrackFX_SetEnabled(pTrack, iPlugin, !TrackFX_GetEnabled(pTrack, iPlugin));
                );
            )
        );
        
        // Construct return value
        TrackFX_GetOpen(pTrack, iPlugin) ? ret = 1;
        TrackFX_GetEnabled(pTrack, iPlugin) ? ret |= 2;
    )
    :
    (
        MB(sprintf(#, "%s not found!", sPluginName), "Plugin not found", 0);
    );
    
    ret;
);

Undo_BeginBlock2(0);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(pluginName, track, toggleActive, create, extFX);
Undo_EndBlock2(0, sprintf(#, "Toggle %s visible", pluginName), 2);
Thank you for your assistance.
Joe90 is offline   Reply With Quote
Old 01-19-2020, 07:48 PM   #37
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Quote:
Originally Posted by Joe90 View Post
The version Fox posted above will float/unfloat a plugin by name for me, but it still doesn't create it.
It's optional. At the bottom you just change this:
ShowNamedPlugin(sPluginName, pTrack, 0);
To this:
ShowNamedPlugin(sPluginName, pTrack, 1);

If you the newer version posted by IXix, I bet you just need to ensure that the main script is named ShowNamedPlugin.func.eel and you selected eel from the dropdown when you saved it (or it will add .lua and not work) and that it's saved in the same place as the per-plugin scripts.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 01-20-2020, 05:02 AM   #38
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Joe90 View Post
Hi IXix - I'm sorry, but I'm still having no luck with this...
As foxAsteria said, make sure the script is saved as an .eel file. That's the only thing I can think of as to why it wouldn't be working.
IXix is offline   Reply With Quote
Old 05-25-2020, 09:48 PM   #39
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

Hi all,

This is the version of Ixix's script I am using, and it's working great. The only issue is that it doesn't work for custom FX chains that I've saved -

Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "The Drop";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
Anyone know how to get it working for FX chains too?

Thanks for your help.
Joe90 is offline   Reply With Quote
Old 05-26-2020, 08:15 PM   #40
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Quote:
Originally Posted by Joe90 View Post
Anyone know how to get it working for FX chains too?
Shouldn't matter if you've got the plugins named the same as what the script looks for.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.