Use GPScript to bypass plugins automatically when volume is off

Dec 23, 2018 | Gig Performer Blog, GP Script, Tips

Gig Performer is pretty efficient in terms of CPU cycles but sometimes plugins use up a lot of cycles even when they’re (apparently) not doing anything. In a traditional channel strip model, it’s pretty straight forward to automatically bypass plugins when the channel strip fader goes to 0 (well, -infinity) because it’s immediately obvious what to bypass since the channel strip “owns” the plugins.

In the Gig Performer world, you can of course connect a single plugin to an arbitrary collection of other plugins and so there is no implicit ability to bypass a plugin. However, with a little bit of GPScript (Gig Performer’s proprietary scripting language), it’s very easy to tailor this behavior to suit your specific needs.

Let’s see a simple example:

So in this brand new gig, we have inserted a plugin called Aalto. It’s not connected to anything yet but our CPU monitor (which specifically monitors total audio processing) is showing that Aalto is using around 27% even though no audio is being processed or produced from it.  (NB – normally when you insert a new plugin, the quiescent CPU utilization might go up by 1 – 2%, but that’s all.

Anyhow, let’s finish connecting this up so we have a working example.

Now we have a synth, controlled from an incoming MIDI keyboard, with audio going through a gain control and finally to output. So what we’d like to do now is arrange for the Aalto to be completely bypassed when the gain is sufficiently low so that the sound is no longer audible. To do this, we have to make the Aalto plugin and the Gain/Balance plugin accessible to GP Script. We do this by right-clicking on each of the plugins and assigning them GPScript names.

Let’s start with the Aalto: right-click on the Aalto plugin and navigate to OSC/GPScript->Set name…

Now you will see a new dialog.

Type in a meaningful name (which can be composed of only letters and numbers), check the “Use in GPScript” box and then click OK

The plugin now displays its GPScript name on the top left and there’s also an indicator on the right {S} indicating that this plugin can now be used in Gig Performer scripts.

Do the same thing for the Gain/Balance plugin, for example:

You can see that the Gain/Balance plugin now also has a GPScript name, SynthVol

Now open the Script Editor window (Window -> Show Script Editor)

You should see a new empty window that looks like this:

You’re now ready to write the script – but don’t worry, we have a few tools to help you.

First, right-click inside the editor and select the menu item, “Auto declare blocks and widgets”

After you do this, the contents of the Script Editor window will change:

Don’t worry if you don’t understand this right now — we are telling the scripting system what plugin blocks it can now access. As you become more proficient with scripting (if you so desire, you don’t have to use scripting), you will start to write these lines manually.

Next, right-click again inside the editor and select “Plugin block parameter changed callback”. A callback is a chunk of code that will be called automatically when something happens. In particular, we are going to configure this callback so that it responds whenever the gain of the Gain/Balance plugin changes.

This will insert some new lines into the script:

The items surrounded by < and > are hints to tell you what has to be changed by you. First, we’re going to indicate that this callback should be triggered from the Gain/Balance plugin. If you recall from earlier, we gave the Gain/Balance plugin the GPScript name SynthVol. We don’t need any local variables so we will also delete that <Local variable declarations> section. Now this section of the code looks as follows:

Note the two variable names, parameterNumber and parameterValue that are part of the callback declaration. All plugins that support host automation have unique parameter numbers associated with each item of the plugin that can be controlled from the plugin host. Gig Performer makes it easy for you to find the parameter number simply by moving the desired parameter.

Here’s a picture of the Gain/Balance control plugin editor window right after I moved the fader. Notice at the top, there’s a line that says, Param# 0. That means that the parameter number for the fader is 0

The parameterValue variable will always be a value between 0.0 and 1.0

So now we can complete the script by checking the parameter number and we will bypass (or unbypass) based on the value of the fader.

So whenever the fader value is less than 1% from the bottom, we bypass the AaltoPlugin, otherwise we unbypass it.

Now press the Compile button and if all is well, you will see a nice confirmation:

GPScript code in GPScript editor, compile code, Gig Performer

Let’s take a look at this in action:

Notice that as you move the fader towards 0, the plugin automatically bypasses and the CPU utilization falls instantly.


Related topics:
The most flexible MIDI processing
How to control multiple parameters with a single widget? (GPScript example)
GPScript Documentation