Open/Close Plugin on Selected track Key Commands

Hello my friend, yes and no :slight_smile:
We need obviously a loop, correct, however I dislike blocking threads, i.e., it’s better that we create custom vars to trigger next slot activation and pseudo-timing this.
Then, the “Edit plugin” command, though I haven’t tried it, seems to me that it’s a toggle command. This means that if we use it, and we want to open all plugins, but some of them are already shown, they will get hidden. Instead I’ve used the mEdit hostValue.

Below is the code, I’m not particularly happy with it, but seems to be working at testing, and we all know that testing is usually far from a real-life situation.

Anyway, here it is:

var midiremote_api = require('midiremote_api_v1')

var deviceDriver = midiremote_api.makeDeviceDriver('Test', 'Test Script', 'Test')

var midiInput = deviceDriver.mPorts.makeMidiInput("loopMIDI Port 1")
var midiOutput = deviceDriver.mPorts.makeMidiOutput("loopMIDI Port")

var detect = deviceDriver.makeDetectionUnit()

detect
    .detectPortPair(midiInput, midiOutput)
    .expectInputNameEndsWith("loopMIDI Port 1")
    .expectOutputNameEndsWith("loopMIDI Port")
    
var surface=deviceDriver.mSurface

var buttonInsertsShow=surface.makeButton(0,0,1,1)

buttonInsertsShow.mSurfaceValue.mMidiBinding
    .setInputPort(midiInput)
    .bindToControlChange(0,24)


var page=deviceDriver.mMapping.makePage("aPage")

var insertsViewer=page.mHostAccess.mTrackSelection.mMixerChannel.mInsertAndStripEffects.makeInsertEffectViewer("insertsViewer")
insertsViewer.excludeEmptySlots()

var dummyInitProcess=page.mCustom.makeHostValueVariable("dummyInitProcess")
var customNextInsert=surface.makeCustomValueVariable("customNextInsert")
var customShowInsert=surface.makeCustomValueVariable("customShowInsert")
var customPseudoTimer=surface.makeCustomValueVariable("customPseudoTimer")
var pseudoTimerCounts=9

page.mOnActivate=function(activeDevice){

    activeDevice.setState("showHide","0")
   
}


page.makeValueBinding(buttonInsertsShow.mSurfaceValue,dummyInitProcess).mOnValueChange=function(activeDevice,activeMapping,value){
    
    activeDevice.setState("initialized","1")
    activeDevice.setState("countingDuplicates","0")
    activeDevice.setState("showHide",(1-parseInt(activeDevice.getState("showHide"))).toString())
    insertsViewer.mAction.mReset.trigger(activeMapping)

}


insertsViewer.mOnTitleChange=function(activeDevice,activeMapping,title){
    
    var initialized=activeDevice.getState("initialized")
    var previousIndex=activeDevice.getState("insertIndex")
    if(previousIndex==""){previousIndex="0"}
    var previousIndexInt=parseInt(previousIndex)
    var currentIndexInt=parseInt(title)
    activeDevice.setState("insertIndex",title)
    
    if(initialized=="1" && (currentIndexInt==previousIndexInt)){
        
        var countingDuplicatesInt=parseInt(activeDevice.getState("countingDuplicates"))+1
        
        if(countingDuplicatesInt>3){
            
            initialized="0"
            activeDevice.setState("initialized",initialized)
            activeDevice.setState("countingDuplicates","0")
            customShowInsert.setProcessValue(activeDevice,parseInt(activeDevice.getState("showHide")))
        
        } else {

            activeDevice.setState("countingDuplicates",countingDuplicatesInt.toString())

        }
    
    } else if (initialized=="1"){

        activeDevice.setState("countingDuplicates","0")

    }
    
    if(initialized=="1"){
     
        customPseudoTimer.setProcessValue(activeDevice,0)
    
    }
    
}

customPseudoTimer.mOnProcessValueChange=function(activeDevice,value){
    
    value++
    
    if(value>pseudoTimerCounts){
    
        var currentIndexInt=parseInt(activeDevice.getState("insertIndex"))
        customNextInsert.setProcessValue(activeDevice,currentIndexInt/16)
    
    } else {

        customPseudoTimer.setProcessValue(activeDevice,value)
    
    }

}

page.makeActionBinding(customNextInsert,insertsViewer.mAction.mNext).mOnValueChange=function(activeDevice,activeMapping,value,diff){
    
    var initialized=activeDevice.getState("initialized")
   
    if(initialized=="1"){
   
        customShowInsert.setProcessValue(activeDevice,parseInt(activeDevice.getState("showHide")))

    }    
    
}

page.makeValueBinding(customShowInsert,insertsViewer.mEdit)

I obviously agree. Though MR can offer solutions/workarounds, such cases are easy for Steinberg’s devs to deal with and provide key commands :slight_smile:

2 Likes

Isn’t this now listed as key command option in Key Commands > Windows > Show/Hide Plugins

Hello, this command works as expected, when we have previously opened one by one our plugins. In fact, I much prefer this, instead of the above workaround, since I never want all of them open at the same time.

Nice!

I did exactly the same job, but it didn’t work.
It says “If action” is currently false.

the cubase show/hide plugins shows and hides ‘ALL’ the plugins in yor project??? why would you ever want t do that?

Surely the command should work on the selected track only and open those… no?

Is there a way to do this?

M