Two ways:
The first (old) is to create a sufficiently large bank of parameters, and then bind your knob to the parameter you want by its index. I think that @mlib is perhaps referring to this.
The second uses the directAccess object. Note that is is more low-level, and it will then be up to you to properly handle the MIDI messages of your knob (absolute, relative, etc).
Each parameter has a “tag” and you can query the tags of the parameters and console.log them, so you can find out the tag of the one you want. You can even setup a function searching for the tag, by matching the parameter’s name.
Check this example of controlling a parameter for the plugins “Mono Delay” and “Revelation” and their parameters “Feedback” and “Pre-Delay” when they’re in the first insert slot.
// @ts-nocheck
var midiremote_api = require('midiremote_api_v1')
var deviceDriver = midiremote_api.makeDeviceDriver("Test","Control Parameter","mc")
var midiInput = deviceDriver.mPorts.makeMidiInput("anInput")
var midiOutput = deviceDriver.mPorts.makeMidiOutput("anOutput")
var detectionUnit=deviceDriver.makeDetectionUnit()
detectionUnit.detectPortPair(midiInput,midiOutput)
.expectInputNameEquals("Bome MIDI Translator 1")
.expectOutputNameEquals("Bome MIDI Translator 1")
var surface=deviceDriver.mSurface
var customKnob=surface.makeKnob(0,0,1,1)
customKnob.mSurfaceValue.mMidiBinding
.setInputPort(midiInput)
.bindToControlChange(0,0)
var mapping=deviceDriver.mMapping
var currentMapping
//setting up everything to lower case
var pluginsParams={
"monodelay": ["feedback"],
"revelation": ["pre-delay"]
}
var slotIndex=0 //Handling the first insert slot
var paramTag=-1
var stepRes=1/127 // The step. We can set it to bigger/smaller values
var page=mapping.makePage("Default")
var selTrack=page.mHostAccess.mTrackSelection.mMixerChannel
var insertViewer0=selTrack.mInsertAndStripEffects.makeInsertEffectViewer("insertViewer0")
insertViewer0.accessSlotAtIndex(slotIndex)
var daInsertViewer0=page.mHostAccess.makeDirectAccess(insertViewer0)
insertViewer0.mOnChangePluginIdentity=function(activeDevice,activeMapping,pluginName,pluginVendor,pluginVersion,formatVersion){
paramTag=-1
var pluginNameLow=pluginName.toLowerCase()
if(pluginNameLow in pluginsParams){
var params=pluginsParams[pluginNameLow]
var param0=params[0]
var insertSlotID=insertViewer0.getRuntimeID(activeMapping)
if (insertSlotID==-1){
return
}
//The object containing the plugin is the first child of the slot object
var insertPluginID=daInsertViewer0.getChildObjectID(activeMapping,insertSlotID,0)
var paramNum=daInsertViewer0.getNumberOfParameters(activeMapping,insertPluginID)
if(paramNum==0){
return
}
for(var i=0;i<paramNum;i++){
var paramTagByIndex=daInsertViewer0.getParameterTagByIndex(activeMapping,insertPluginID,i)
var paramName=daInsertViewer0.getParameterTitle(activeMapping,insertPluginID,paramTagByIndex,128)
//A good place to log tags/names for our plugins
//console.log("tag: "+paramTagByIndex+" name: "+paramName)
if(paramName.toLowerCase()==param0){
paramTag=paramTagByIndex
break
}
}
}
}
page.mOnActivate=function(activeDevice,activeMapping){
currentMapping=activeMapping
daInsertViewer0.activate(activeMapping)
}
page.mOnDeactivate=function(activeDevice,activeMapping){
daInsertViewer0.deactivate(activeMapping)
}
customKnob.mSurfaceValue.mOnProcessValueChange=function(activeDevice,value,diff){
var insertSlotID=daInsertViewer0.getBaseObjectID(currentMapping)
if(insertSlotID<1 || paramTag==-1) return
var insertPluginID=daInsertViewer0.getChildObjectID(currentMapping,insertSlotID,0)
var currentParamValue=daInsertViewer0.getParameterProcessValue(currentMapping,insertPluginID,paramTag)
//absolute mode
var newParamValue=currentParamValue+(value==0 || diff<0 ? -1 : 1)*stepRes
newParamValue=Math.max(0,Math.min(1,newParamValue))
daInsertViewer0.setParameterProcessValue(currentMapping,insertPluginID,paramTag,newParamValue)
}