2 Keyboards / 4 Plugins / Auto Bypass (V5)

This rackspace is designed to use two keyboards or one split keyboard (for which is set up now) to vary between two sounds (totals 4 plugins involved) for each LOWER and UPPER keys.
Which one of the two plugins is enabled can be set with an “ACTIVE” pad.
So all in all it just enables you to set one, two or no sound for each keyrange/keyboard, and the unused plugins will be bypassed to save resources.
The clue is that i not only used MIDI-filters to avoid stuck notes because of “missing” NOTE-OFFs, but i also used the Envelope Follower (new in V5) to detect if the outgoing sound of a plugin is really silent (long dealys or reverbs) before switching it to bypass, so a sound can ring out, or can be hold while you can switch to the other sound which of course can instantly be played (and the “old” sound still also plays). That guarantees smooth transitions between sound switching, no surprising “audio zombies” which start to play again when the plugin is revoked from bypass (happens with a lot of plugins!), but yet there are no more plugins active if not used.
BTW: This also works when you switch variations.
I had to use some scripting to make this possible, but it’s not that much.
For each Envelope Follower there is a “Sense” LED which indicates if there is sound detected or not, and also a “Threshold” knob to adjust the loudness of what is detected as “silence”.
Low values will cause the Enveope Follower to be very sensitive, which means the audio might get really soft and silent before detected as “OFF” (good for long reverbs), but this keeps the regarding plugin to stay active for all that time, and active plugins consume resources.
So, that’s something you’d have to try for your own sounds.
I have locked all the widgets from user interaction (mouse) which are handled by the script, so you can’t manually cause unwanted situations which would lead to unpredictable results.
Just exchange the plugins and MIDI blocks with your own ones!
OK… many words, here are some pics:

For the nosy ones, here’s the script which works behind the curtains:

var
// declaration of the single variables
padActiveLO1, padActiveLO2, padActiveUP1, padActiveUP2 : widget //ACTIVE pads
ledSenseLO1, ledSenseLO2, ledSenseUP1, ledSenseUP2 :widget //Sense LEDs of the Envelope Followers
ledBypLO1, ledBypLO2, ledBypUP1, ledBypUP2 : widget //Bypass LEDs of the plugins
mark2BypassLO1, mark2BypassLO2, mark2BypassUP1, mark2BypassUP2 : boolean //marker flags for plugins to be bypassed (when silent)
bypStatusLO1, bypStatusLO2, bypStatusUP1, bypStatusUP2 : double //storage variables for the state of the Bypass LEDs

//declaration of the according arrays
padsActive : widget Array = [padActiveLO1, padActiveLO2, padActiveUP1, padActiveUP2]
ledsSense : widget Array = [ledSenseLO1, ledSenseLO2, ledSenseUP1, ledSenseUP2]
ledsBypass : widget Array = [ledBypLO1, ledBypLO2, ledBypUP1, ledBypUP2]
marks2Bypass : boolean Array = [mark2BypassLO1, mark2BypassLO2, mark2BypassUP1, mark2BypassUP2]
bypStatus : double Array = [bypStatusLO1, bypStatusLO2, bypStatusUP1, bypStatusUP2]

//user function to "store" the actual state of evry Bypass widget in an array
function getBypStatus()
var
index : integer
    for index = 0; index< Size(ledsBypass); index = index +1 Do
        bypStatus[index]=GetWidgetValue(ledsBypass[index])
    end
End


Initialization
var
index : integer
//set the Bypass markers to a defined state
    for index = 0; index< Size(marks2Bypass); index = index +1 Do
        marks2Bypass[index] = false
    end
    getBypStatus()
End

//caled when one of the ACIVE pads changes its state
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from padActiveLO1, padActiveLO2, padActiveUP1, padActiveUP2
    If newValue<0.4 and GetWidgetValue(ledsSense[index])==0.0 then //if de-activated AND there is no sound detected
        SetWidgetValue(ledsBypass[index],1.0) //set the bypass widget
        marks2Bypass[index] = false //clear the bypass mark (was bypassed directly)
    elsif newValue<0.4 and GetWidgetValue(ledsSense[index])==1.0 then //if de-activated AND there is still sound dtected
        marks2Bypass[index] = true // set a "to-be-bypassed" flag for that widget (but do nothing else, means: don't bypas it yet)
    elsif newValue>0.6 then //if activated
        SetWidgetValue(ledsBypass[index],0.0)//unbypass the widget/plugin
        marks2Bypass[index] = false//clear the "to-be-bypassed" flag for that plugin
    end
    getBypStatus()//call the user function to store the bypass states
End

//caled when one of the sense-LEDS changes its state
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from ledSenseLO1, ledSenseLO2, ledSenseUP1, ledSenseUP2
    if newValue < 0.4 then//if it goes OFF (means: no sound detected anymore)
        if marks2Bypass[index] == true then//check if there is a "to-be-bypassed" flag for that plugin, if yes
            SetWidgetValue(ledsBypass[index],1.0)//bypass it (since there is no sound detected anymore)
            marks2Bypass[index] = false//clear the "to-be-bypassed" flag for that plugin again (has just been bypassed)
        end
    end
    getBypStatus()//call the user function to store the bypass states
End

// Called when you switch variations
On Variation(oldVariation : integer, newVariation : integer)
var
//on any variation change, the previousy saved states of the bypass LEDs is restored
//so that sounds play on until finished or released, even if the variation says it should have been bypassed
index : integer
    for index = 0; index< Size(ledsBypass); index = index +1 Do
        SetWidgetValue(ledsBypass[index],bypStatus[index])
    end
End


Oh, yes… here is the gig file:
2 Keyboards - 4 sounds(auto bypass).gig (411.9 KB)

May it be useful and bring you some fun!

6 Likes

Elegant solution :+1:

2 Likes