ctrlValue:setOverlayId limits the values to choose from ; a work around

Hi,

for controlling effects, I create faders for its parameters for which their nature depends on the type of FX parameter to control.
It’s fairly easy to do with lua such as in the excerpt example below:

        control = controls.get (i)
        control:setVisible (ctrlVis) -- controls visibility
        control:setName (pair[3 + i*5])  -- controls the name
        control:setColor(pair[4 + i*5]) -- controls the color
        ctrlValue = control:getValue ("")
        ctrlValue:setMin (pair[5 + i*5]) -- sets min display value
        ctrlValue:setMax (pair[6 + i*5]) -- sets max display value
        message = ctrlValue:getMessage () 
        message:setMax (pair[6 + i*5] - pair[5 + i*5]) -- sets max MIDI value
        ctrlValue:setOverlayId (pair[7+i*5]) -- set the overlay to use

But I have some trouble with overlays.

Most overlays have a limited amount of values between 2 and 100, so they can be defined within lua like:

  overlayTable =  {{ value = 0, label = "Sine" },{ value = 1, label = "Triangle" },{ value = 2, label = "Peak" },
    { value = 3, label = "Random" },{ value = 4, label = "Ramp" },{ value = 5, label = "Square" }}
  overlays.create(350, overlayTable)

There are however 2 overlays for faders that have a range of 2014 and even 4022 different values. Only 14, resp. 22 of these (the last ones of the fader) need a special label.

If you create a specific fader with its own Overlay defined via the web editor, it’s perfectly okay to only assign labels to those 14 resp. 22 values, and still use the full range.
But when you assign such an overlay via “ctrlValue:setOverlayId” , the values to choose from are limited to those in the Overlay. So only the range 2001-2014 resp. 4001-4022 is available, which is not desired.

Is there a way to work around it?

I’ve made a work around by constructing the overlay withing lua.
In the example the first 191 values are straightforward.
So I create a string with the desired definition by concatenating it. As it starts with “return” it will behave as a function once loaded, creating the overlay table.

  local overlayString = " return {"
    for i = 0,190 do
      overlayString = overlayString..string.format('{value= %d, label= "%.1f"},', i, 1+i/10)
    end
  overlayString = overlayString..'{ value = 191, label = "1/32 note" },{ value = 192, label = "1/16 note" },{ value = 193, label = "1/12 note" },{ value = 194, label = "3/32 note" },{ value = 195, label = "1/8 note" },{ value = 196, label = "1/6 note" },{ value = 197, label = "3/16 note" },{ value = 198, label = "1/4 note" },{ value = 199, label = "3/8 note" },{ value = 200, label = "2/4 notes" },{ value = 201, label = "3/4 notes" },{ value = 202, label = "4/4 notes" },{ value = 203, label = "5/4 notes" },{ value = 204, label = "6/4 notes" },{ value = 205, label = "7/4 notes" },{ value = 206, label = "8/4 notes" },{ value = 207, label = "9/4 notes" },{ value = 208, label = "10/4 notes" },{ value = 209, label = "11/4 notes" },{ value = 210, label = "12/4 notes" },{ value = 211, label = "13/4 notes" },{ value = 212, label = "14/4 notes" },{ value = 213, label = "15/4 notes" },{ value = 214, label = "16/4 notes" },{ value = 215, label = "17/4 notes" },{ value = 216, label = "18/4 notes" },{ value = 217, label = "19/4 notes" },{ value = 218, label = "20/4 notes" }}'
  local tableFunction = load(overlayString)
  overlayTable = tableFunction()
  overlays.create(303, overlayTable)

Next challenge are 2 overlays of 2014 and 4022 values. Fingers crossed!
EDIT : I just finished making them the very same way. It takes a bit to load, but they work, and it is easier than typing it all in.

The work around is no good: after having had to make more than of those dynamics overlay, each with at least 1000 of labels, the E1 loading became very slow.
So I skipped the idea of dynamic overlays for these occassions, and replaced it with a dynamic formatter. That entails the controller always has the same formatting function, but the function’s behaviour is changed according to the effects type. It loads much faster than the crafted overlays.

something like:

if     formatToApply[i]==0    then return string.format("%d",value)
  elseif formatToApply[i]==10090 then return string.format("%.1f",1+value/10) -- 1.0–10.0
  elseif formatToApply[i]==10052 then 
     labels = {"1/4","1/2","3/4"}
    if value <= 2 then return labels [value] end
    return string.format("%d",value-2) --1/4, 1/2, 3/4, 1–50
  elseif formatToApply[i]==11915 then -- 0- 1900,1/16,1/12,3/32,1/8,1/6,3/16,1/4,3/8,2-8/4
    if value <= 1900 then return string.format("%d",value)
      elseif value <= 1900+8 then return labels [value+1-(1900)]
      else return string.format("%d/4 notes",value-(1900+8-1))
    end
...