Bypassing or Viewing all insert effects slots with one-button push, using the Midi Remote

Hi, in some threads I saw a request for bypassing and/or viewing all insert effects slots of the selected track, simultaneously with one button push.

Using the MIDI Remote API, here’s a snippet for this one. Note that while it works as expected here, I cannot guarantee this would be stable enough in other systems.
Show All is bound to MIDI CC 32, while Bypass All to 33, both at Channel 1 (0). You can obviously change these.

var midiremote_api=require('midiremote_api_v1')

var deviceDriver = midiremote_api.makeDeviceDriver('Test Devices', 'A test Device', 'Someone')

var midiInput = deviceDriver.mPorts.makeMidiInput()
var midiOutput = deviceDriver.mPorts.makeMidiOutput()

deviceDriver.makeDetectionUnit().detectPortPair(midiInput, midiOutput)
    .expectInputNameContains('a port')
    .expectOutputNameContains('an output port')

deviceDriver.mOnActivate=function(activeDevice){

    activeDevice.setState("insertsViewerState0","0")
    activeDevice.setState("insertsViewerState1","0")
    activeDevice.setState("insertsViewerEditCountSlots","0")

}
    
var surface=deviceDriver.mSurface

var editOrByPassButons=[]
var editOrBypassVars=[]
var resetOrNextVars=[]

for(var i=0;i<2;i++){

    editOrBypassVars.push(surface.makeCustomValueVariable("editOrByPass"+i))
    resetOrNextVars.push(surface.makeCustomValueVariable("resetOrNext"+i))

    var aButton=surface.makeButton(i,0,1,1)
    aButton.mSurfaceValue.mMidiBinding
        .setInputPort(midiInput)
        .bindToControlChange(0,0x20+i)
    

    editOrByPassButons.push(aButton)

    editOrByPassButons[i].mSurfaceValue.mOnProcessValueChange=function(activeDevice,value,diff){

        if(value==0){return}
    
        var previousState=parseInt(activeDevice.getState("insertsViewerState"+this.i))
        var newState=1-previousState 
        
        activeDevice.setState("insertsViewerState"+this.i,""+newState)
        activeDevice.setState("insertsViewerCountSlots",""+maxInsertSlots)
        activeDevice.setState("insertsViewerSlotsVisited","")
        activeDevice.setState("insertsViewerEditOrBypass",this.i.toString())
        
        resetOrNextVars[0].setProcessValue(activeDevice,1)
        
    }.bind({i})

}

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

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

insertsViewer.followPluginWindowInFocus()

var maxInsertSlots=midiremote_api.mDefaults.getNumberOfInsertEffectSlots()

aPage.makeActionBinding(resetOrNextVars[0],insertsViewer.mAction.mReset)
aPage.makeActionBinding(resetOrNextVars[1],insertsViewer.mAction.mNext)

aPage.makeValueBinding(editOrBypassVars[0],insertsViewer.mEdit)
aPage.makeValueBinding(editOrBypassVars[1],insertsViewer.mBypass)

insertsViewer.mOnTitleChange=function(activeDevice,activeMapping,slotIndex){
    
    var slotsCount=parseInt(activeDevice.getState("insertsViewerCountSlots"))
    
    if(slotsCount>0){

        var key="~"+slotIndex+"~"
        var slotsVisited=activeDevice.getState("insertsViewerSlotsVisited")
        if (slotsVisited.indexOf(key)==-1){
        
            slotsVisited=slotsVisited+key 
            activeDevice.setState("insertsViewerSlotsVisited",slotsVisited)
            
            slotsCount--
            activeDevice.setState("insertsViewerCountSlots",slotsCount.toString())
            
            var insertsViewerEditOrBypass=activeDevice.getState("insertsViewerEditOrBypass")
            var insertsViewerState=parseInt(activeDevice.getState("insertsViewerState"+insertsViewerEditOrBypass))
            
            editOrBypassVars[parseInt(insertsViewerEditOrBypass)].setProcessValue(activeDevice,insertsViewerState)
            
        }

    }
    
}

insertsViewer.mEdit.mOnProcessValueChange=function(activeDevice,activeMapping,value){
    
    insertsViewerGoToNextSlot(activeDevice,0)
    
}

insertsViewer.mBypass.mOnProcessValueChange=function(activeDevice,activeMapping,value){

    insertsViewerGoToNextSlot(activeDevice,1)

}

function insertsViewerGoToNextSlot(activeDevice,editOrByPass,value){
  
    var insertsViewerEditOrBypass=parseInt(activeDevice.getState("insertsViewerEditOrBypass"))
    
    if(insertsViewerEditOrBypass==editOrByPass){

        var slotsCount=parseInt(activeDevice.getState("insertsViewerCountSlots"))
    
        if(slotsCount>0){
           
           resetOrNextVars[1].setProcessValue(activeDevice,1)

        }
            
    }

}

And here’s a smart demo:

2 Likes