Best way to customize a panel with external files, variables, Scripts?

Hi all,

I created a panel with four banks and 16 parameters each, which show and change the
values on my MIDIFighter Twister.

What´s the most elegant way to customise the names/colors of the faders and the titles
of the bank?

I suppose, this can be done with variables.
As this is a fairy basic question compared to the other topics in the forum, I´m quite
sure You guys have solved this a hundred of times and can point my to a good example
I can study.

Instead of changing the properties of more than 100 Widgets for each use case,
it would be nice to just make changes in one single Script or an external file, which is loaded
during the start of the JSON file.

Is this possible and how would one do this?

Any help is appreciated.
Best

1 Like

Btw, this is how my setup looks like, and I like it a lot.
Mobile phone acts as visualisation of the Twister.
Phone updates Twister and vice versa. And both control parameters
via BOME MIDI Translator parameters in my DAW.
More flexible and cooler than I intendet it to be..... :grinning:
Phone acts like a remote control as well. So I can walk around and
change paramters from outside of my studio.
Not realy needed, but I CAN if I want to.... :rofl:

image

nice !!
I like the way you manage the label and value of the faders !

You could create a json file right next to the session file containing your mapping:

{
  "bank1": {
      "0": {"label": "Bass", "color": "#ff0000"},
      "1": {"label": "Synth", "color": "#ffff00"}
  },
  "bank2": {
      "0": {"label": "Bass2", "color": "#ff0000"},
      "1": {"label": "Synth2", "color": "#ffff00"}
  }
}

Then in the value property of a variable widget you'd write:

JS{
var mapping = {}
var userMapping = IMPORT{map.json}
if (userMapping) userMapping = JSON.parse(userMapping)


// build mapping with a fallback to a default value for every bank/fader 
// in case the file is not loaded yet or if a fader is not defined in the mapping
for (var bank of ["bank1", "bank2", "bank3", "bank4"]) {

  mapping[bank] = {}

  for (var i=0; i<16; i++) {
    if (userMapping && userMapping[bank] && userMapping[bank][i]) {
      mapping[bank][i] = userMapping[bank][i]
    } else {
      mapping[bank][i] = {label: "None", color: "Grey"} 
    }

  }
}

return mapping

}

You'd then retrieve the label and color values dynamically where you used to write them:

Bank1 / fader 0 / label

#{@{mapping_variable_id}.bank1[0].label}

Bank2 / fader 4 / color

#{@{mapping_variable_id}.bank2[4].color}

etc.

What's cool is that editing the mapping file will update the session automatically. That's just one way to do it, YMMV of course.

That looks promissing! Will try!
Thanks Jean-Emmanuel!!