A generic function for hiding controls based on a parameter value

In the last V0.3 version of Electra One App, I’ve made a generic ‘hideCtrl’ function for hiding controls.

In the elements of table ctrl2Hide you tell:

  • which parameter will influence
  • what control,
  • based on which value,
  • and whether it needs to be visible then or not.

The function only works when only one value of the parameter is making the difference between a control being visible or not.

Add the function only to the controlling parameters.
Parameter 12047 is a switch you can add: the hidings will then only work if the switch is On. This way you can temporarily cancel the hiding effect.

function hideCtrl(valueObject, value) --- hides non used parameters
  -- table element: {paramNumber,ctrl2change,value2check, boolVis at value2check}
  local ctrl2Hide={{22,75,0,true},{22,76,0,true},{25,82,0,false},{25,78,0,false},{25,79,0,false},{25,80,0,false}, --legato,portamento
    {4100,136,1,true},{4100,137,1,true},{4100,138,1,true},{4100,139,1,true}, -- TMT velo control switch
    {11212,290,1,true},{11209,270,0,true},{11209,271,0,true},{11209,272,0,false},{11209,273,0,false}, -- HOLD switch, tone FX send
    {11245,183,1,true},{11245,184,1,true},{1027,403,1,false}, -- FXM switch , Chorus Out
    {11301,346,10,false},{11301,348,10,false},{11315,363,10,false},{11315,369,10,false} -- LFO1 LFO2
  local paramNumber = valueObject:getMessage ():getParameterNumber ()
  local boolVis = true
  for _, pair in ipairs(ctrl2Hide) do
    if pair[1] == paramNumber then
      control = controls.get (pair[2])
      if pair[3] == value then boolVis = pair[4] else boolVis = not(pair[4]) end
      if parameterMap.get (deviceId, PT_VIRTUAL, 12047) == 0 then boolVis = true end --- override the hide modes
      control:setVisible (boolVis)    
1 Like