Un-ending loop with AU plugin

I have a Gig file with 3 rackspaces for the Cory Wong Archetype, one for each plugin format (AU, VST, VST3).

I have written a script to update the widgets in the rackspace when plugin parameters change (usually by switching presets in the plugin).

The script works properly with the VST and VST3 plugins. However, the AU plugin becomes stuck in an un-ending loop after switching the preset the first time.

Here is the script for the AU rackspace.

var CORY_WONG : PluginBlock
var W4, W5, W6, W7, W9, W25, W26, W27, W31, W35, W54, W57, W58, W64, W66, W68, W70, W71, W72, W74, W89, W92, W103, W107, W108, W111, W115, W116, W117, W119 : widget
var WIDGET_ARRAY : Widget Array = [W4, W5, W6, W7, W9, W25, W26, W27, W31, W35, W54, W57, W58, W64, W66, W68, W70, W71, W72, W74, W89, W92, W103, W107, W108, W111, W115, W116, W117, W119]
var PARAM_ARRAY : Integer Array = [4, 5, 6, 7, 9, 25, 26, 27, 31, 35, 54, 57, 58, 64, 66, 68, 70, 71, 72, 74, 89, 92, 103, 107, 108, 111, 115, 116, 117, 119]

// Set widget to match plugin parameter change
On ParameterValueChanged(parameterNumber : integer, parameterValue : double) from CORY_WONG
var i : integer

    for i = 0; i < Size(PARAM_ARRAY); i = i + 1 do
        if PARAM_ARRAY[i] == parameterNumber then SetWidgetValue(WIDGET_ARRAY[i], parameterValue) end
    end

End

The only difference in the script of the other rackspaces are the parameter numbers and widget names.

I have attached a short video of the un-ending loop.

Hmm…
i’m wondering why you have to “manually” update your widgets with a script?
Normally you would connect the widgets with the regarding parameters of the plugin and then this connection will work in a bidirectional way, so there wouldn’t be any need for scripting.
It’s just a guess, but have you accidentially connected the widgets of your “AU-rackspace” with the parameters of the plugin AND use the script at the same time? Then this would lead to an endless loop… changing a parameter → updating the widget → updating the parameter → updatig the widget… etc. etc.

BTW: The video you tried to upload isn’t working… maybe try another format?

Some Plugins do not notify the Host about changes when presets are choosen within the plugins inbuilt preset mechanism.

I can tell from my own first-hand experience that “NDSP Cory Wong” surely does!
I just have built some rackspaces for it too… :wink:

As already commented, there is the question of why you need to do this?

The likely cause is what @schamass has said.

The thing you could add to the script is a test of the existing widget value before you change it → if it already has the required value then you don’t need to set it again.

for i = 0; i < Size(PARAM_ARRAY); i = i + 1 do
        if PARAM_ARRAY[i] == parameterNumber then 
             if GetWidgetValue(WIDGET_ARRAY[i]) <> parameterValue then SetWidgetValue(WIDGET_ARRAY[i], parameterValue) end
        end
end

Why not replacing your loop by:

SetWidgetValue(WIDGET_ARRAY[IndexOf(PARAM_ARRAY, parameterNumber)], parameterValue)

If the values of both array are not perfectly aligned, it could be that you could easily run in an endless loop. I would more than carefully check this.

Furthermore, I am wondering why you don’t simply map a widget to a plugin parameter and let GP do the widget update when a parameter changes? :thinking:

Because some plugins do not send their parameter values when presets are changed via the plugins preset mechanism.

Then the On ParameterValueChanged won’t be called either.

Thank you for the various replies.

Based on the responses, I rebuilt the file. Best I can tell, the original file was corrupted.

I can confirm the three formats of Archetype Cory Wong 2.0 (AU, VST, VST3) do update widgets when changing presets in the plugin.

However, the VST3 format for 2.0 has a drastically longer load time than for 1.0.