New tool (3.3.0): Arturia KeyLab mkII v1.3 build 023 (January 2021)

Hey Raul,

thanks for your efforts writing this tool. I was looking into your source to find something which could be used for a Keylab/Minilab MK3 tool… Sadly the code structure seems to be somewhat chaotic. Did you somehow run your code thru a obfusciator or simplifying tool or something?

If not, I would highly recommend to you to read/think about “mapping”, “multidimensional objects”, like for example, you can of course use tables within tables. Instead numeric indices, you can use words. Instead putting all tooltips into a single table, you could put the tooltip into the “fader description” table instead.

You can also map functions within a table. No need for doing long if else clauses here.

Just a loose example for a better data / config structure:

faders = {
  awesomeFader1 = {
    label = "Fade away",
    toStringConverter = function () ... end,
    toNumberConverter = function () ... end,
    tooltip = "What a nice tooltip",
    mappedMidiSysex = { 0xff, 0xfe, 0x01, 0x02 }
  },
  extremePowerFader2 = {
    label = "Fade in",
    toStringConverter = function () ... end,
    toNumberConverter = function () ... end,
    tooltip = "extreme Powerfader tooltip",
    mappedMidiSysex = { 0xff, 0xfe, 0x01, 0x03 }
  },
  ...
}

Then you could simply iterate over this structure in nested loops and build it up, like so, or similar:

for faderKey, values in pairs(faders) do
  print(faderKey, values.label);
  local stringConvertedValue = values.toStringConverter(42 or whatever[faderKey])
  ...
end

Please think about this… I believe this would help you a lot with coding. And also help others who want to contribute, reuse or extend…

Also keep in mind that you also can pass a whole method to another method as parameter, which commonly is then called a “callback method”. Like so:

function renderFader(id, callbackFunction)
   ...
   local tooltipText = faders[id].tooltip
   callbackFunction(tooltipText)
end

renderFader("awesomeFader1", function (tooltipText) showTooltip(tooltipText) end)

This is just an example. I think by knowing these two patterns, you could highly improve and shrink your code, also make it more maintainable and way more human readable (for yourself, too, assuming you are human).

Thanks for consideration and greetings!

Hi ffx.

Before wasting time on other code, it is recommended to study and compare the hardware, to avoid confusion.

The Minilab MK3 has practically nothing to do with the Keylab mkII. Although they are keyboards from the same brand, they work differently. Taking old code from a tool to adapt it to other hardware only serves what you have done, trying to change the way of programming, instead of finishing a new tool for the Minilab.

I appreciate your advice on code that I programmed almost 5 years ago. Until now I have drastically changed my way of programming, since a structure for tools of more than 30,000 lines of code is necessary. And certainly, when I program, even today, I don’t expect another programmer to modify anything. Who is interested in these things in these forums? I think 4 people? There you have it.

I particularly don’t like mixing variables with functions inside tables. I prefer to put variables and functions together within separate tables. I also don’t usually use “for in pairs/ipairs” iterations, I prefer “for do”. And well, calling a function from another function is fine if the called function is used in a multitude of functions.

I use strategic tags a lot in the names of functions and variables. With the search engine, there is nothing faster than that when you have a lot of code.

Thank you for your comments. I assume you have a Minilab mk3 tool on the way.

And well, yes, I’m still a human being :grinning:.

By the way, I haven’t had the Keylab MkII for about 2 years. I bought this keyboard second-hand and resold it. I liked the experience, to a certain extent. Ultimately, I settled on an 88-key keyboard with fewer knobs for composing. Sometimes, less is more.

Ah, I see. Didn’t realize this tool is already this old :blink: I just wanted to get a clue about the effort doing an general MCU (+ special modes for arturia) tool… I currently only have a Minilab 3 and a Behringer Motor 49 thing… Did you manage to display custom text on the display of the Keylab?

Maybe the faderport tool would be somehow a good starting point… Also I am not sure yet if I keep minilab 3. The recent integration in Ableton and Bitwig certainly is one of the best, if not the best, yet still buggy. Also I wonder why integration still is on such a low level.