Make a button to open/close the VST window

Fresh nube in GP here, no experience in scripting at all.
I’m trying to create a simple rack button that show/hide the VST. What I’ve done so far, is tried to copy the working script from one of the factory presets that does that, but has two assigned VST’s, and I need that for five VST’s. So I tried to copy the

var
and the
// Called when a widget value has changed

parts of the script by adding 5 times for each plugin with the names as described on the buttons I’ve placed, and failed miserably at it.

Can I ask for some help, please?

Cheers

Check here…

Thanks David-san,
And apologies for not checking enough for similar posts.

This is precisely the script I was copying, the thing is that I’m not really sure how to use it with multiple VST (say 3,4,5) in one rackspace. I would guess naming the buttons, and placing those names on the right line in the script is a very crucial part of it. I was trying, and trying and it won’t compile on the several attempts and versions I’ve tried, and I guess it’s one of those " ‘Brain.exe’ Stopped responding" moments I’m having here.

Can you please elaborate a little bit on that please…just general rules I have to follow to make it work, whenever you have time for that of coarse.

Thank you!

Did you try the provided gig file which compiles perfectly ?
Regarding compiling errors, how could we help without knowing what you tried to compile ? Please post the script you want to compile.

Sure. Here it goes:

//$<AutoDeclare>

// DO NOT EDIT THIS SECTION MANUALLY
Var
PLUGIN 1: PluginBlock
PLUGIN_1 : Widget
PLUGIN 2: PluginBlock
PLUGIN_2 : Widget
PLUGIN 3: PluginBlock
PLUGIN_3 : Widget
PLUGIN 4: PluginBlock
PLUGIN_4 : Widget
PLUGIN 5: PluginBlock
PLUGIN_5 : Widget
//$

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from PLUGIN_1

If (newValue > 0.5)
Then
OpenPlugin(PLUGIN 1);
Else
ClosePlugin(PLUGIN 1)
End
End

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from PLUGIN_2

If (newValue > 0.5)
Then
OpenPlugin(PLUGIN 2);
Else
ClosePlugin(PLUGIN 2)
End
End

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from PLUGIN_3

If (newValue > 0.5)
Then
OpenPlugin(PLUGIN 3);
Else
ClosePlugin(PLUGIN 3)
End
End

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from PLUGIN_4

If (newValue > 0.5)
Then
OpenPlugin(PLUGIN 4);
Else
ClosePlugin(PLUGIN 4)
End
End

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from PLUGIN_5

If (newValue > 0.5)
Then
OpenPlugin(PLUGIN 5);
Else
ClosePlugin(PLUGIN 5)
End
End

Don’t use spaces in the plugin handles.

1 Like

What rank13 said!
And:
Have you named all your button widgets and plugin blocks corresponding to the names of the variables you are using in your script?
See above pictures and name each of the particular elements accordingly.
You also should propably better use “speaking” names for your buttons and pluginblocks (and the corresponding variables in the script). “Button1” or “Plugin1” is quite abstract.

Here’s the .gig file for more practical example to what I’ve done, or rather failed on. I’m really not sure what’s a better/practical naming for the buttons, since I’d like to use something like that as a platform to build upon, having different versions with different plugins, and I thought it may be much bigger pain if I have to name the corresponding plugin name, and decided on just ‘PLUGIN number’, but if naming it ‘BUTTON’ would make the script work, that’s not a big issue at all.
5 VST Rack.gig (156.7 KB)

Step 1 will be to add the handles to the actual plugin blocks.

Switch to the back/wiring view and right click the plugin block. In the menu will be an option for OSC/GPScript Handle > Set handle…. You need to specify a name here e.g. PLUGIN1. You need to do this for your 5 plugins.

Step 2 will be to edit your script. Rather than manually typing the plugin block and widget handles, simply right-click and select “Auto declare blocks and widgets”. This will add all these names automatically to the top variables (Var) section.

Step 3 will be to go through your script and make sure your references to the plugin blocks match the new/proper name e.g. PLUGIN1

And you should name your buttons as “BUTTON1” and so on…
So you can tell plugins and widgets apart - just by using according names.
That’s what i meant with "use ‘speaking’ names!
Of course you could name your plugins like “pete”, “frank”, “tom” and so on and your buttons as “wilma”, “betty”, “gretchen”… this all would work as well, as long as you used the same names for the same variables in your script.
If i was in your place i would name the buttons as “BTN_1” and so on (numbers), but i would name the plugins by their names, say “plug_ezbass”, “plug_affair”, “plug_lizard”…
So it would be much easier to see what’s going on in your script.

I corrected your gig by renaming the elements and the variables.
(also I removed the “auto assign” of the variables in the script)
5 VST Rack(2).gig (156.8 KB)

2 Likes

Cannot thank you enough! I’ll have a deep look to what you’ve done in the script related to the naming for the variables and try to make some sense of it.
And also, apologies for bothering so many of you here with my stupidness.

Cheers

No problem. You’re welcome.
Don’t hesitate to ask if you have questions… there are many helpful hands here. :beers:

3 Likes

Couldn’t help you further today because of a business trip, but I am happy to see that @schamass did the job very well :wink:

1 Like

Awesome script! Is there any way to make the buttons that open the plugin window momentary? Currently, when you are done with the plugin window and close it, the button is still ON. It would be nice if the light ON status would disappear as soon as the plugin is opened. A workaround is to not close the plugin pop up window but to navigate back to the GP interface and click the button again to turn off, which will close the plugin window, but that’s not as convenient or a natural way of normally working with open windows. Even without this feature, its a nice script! Thanks!

Of coarse it is possible to make them momentary, just unclick that option on each button

Sure, this is possible too.
If you change the particular code blocks for each button to this, the script does exactly what you want:
(Take care of the correct numbering of BUTTONs and PLUGINs)

// On a value change of the widget BUTTON_1, store this value in the temporary variable newValue
On WidgetValueChanged(newValue : double) from BUTTON_1

  If (newValue > 0.5)  //check if that value is greater than 0.5
                       //(0-0.5 means the widget is OFF, >0.5 to 1.0 means the widget is ON)
  Then
    OpenPlugin(PLUGIN_1); //open the plugin with the handle-name "PLUGIN_1"
    SetWidgetValue(BUTTON_1,0) //set the value of the widget named "BUTTON_1" to 0 (=OFF)
  End
End

So what have i done?
I removed the “else” and the following “ClosePlugin” option from the “if clause”, so the script will no
longer react to any OFF-switching, which formerly would have caused the script to close the plugin again, so the plugin will just stay opened.
In addition i switched the widget to “OFF” again, after the command to open the plugin.
No witchcraft neccessary. :face_with_monocle: :upside_down_face:

@ValioKeys:
No, you’ll also have to change the script, else you would get strange effects! :crazy_face:
The “Momentary to latching” option only works if you midi-learned that widget to a MIDI controller that gives you a momentary signal.

Means, if you have a momentary button on your controller, the widget would follow the switch-state of the button, if this “momentary to latching” id deactivated.

Press controller button -ON, release it=OFF.

If you activate his option:
press controller = ON
release = ON
press again = OFF
release again = OFF

And this is also what a plugin would do while the value of that widget changes
(without having changed the script)

momentary active:
press controller -> widget ON -> plugin opened
release controller -> widget OFF -> plugin closed

If you have the “momentary to latching” switched on:
press controller widget ON -> plugin opened
release widget ON -> plugin opened
press again -> widget OFF -> plugin closed
release again -> widget OFF -> plugin closed

hope this helps… :slight_smile:

Yes, I do have the buttons mapped to a controller, and all works perfectly as expected with ‘Momentary to latching’ ticked On or Off without any hiccups what so ever, I just tried it. LED’s light up only when the plugin window is opened and turns off when it’s closed pressing/releasing the same button that opened it.

But as far I understand @ztones, he wants the LED to respond to manually closing the plugin window itself maybe with a mouse instead of pressing the software button on GP which may be obstructed by the plugin window, in which case the LED will stay On until is mouse clicked again. I don’t know if it’s possible the script to be aware of the state or the presence of the plugin window so the LED on GP would reacts accordingly.

Thanks very much! I’m learning! :slight_smile:

1 Like