Note to self (and maybe others) for how to not update range and default value

Well, well, well. I’ve now learned the hard way that you can’t update the min/max range or default value on the Value Object of a control from within the function specified in the web editor that is called upon for any value changes to that specific control. The E1 does go into a very nasty loop.

As an advocate of the software design principle “Separation of concerns” I very much want to be able to update the range and default value from within a scope of logic that does concern the control, and NOT let some other function attached to some other control have to update it.

Thoughts? :expressionless: :slight_smile:

I’ve had to dynamically change those attributes and others for my presets. My typical user case is that a common parameter (say delay time) may have a different range or maybe different display format, so I’d change those when the user selected a patch that used a different algorithm.

I always viewed it as part of the setup for the patch rather than having a self-aware control that reacted to a change in the environment.

2 Likes

Although I understand your point, there are also reasons why things are set up as they are.

Whenever the display value properties are changed (min, max, default), electra will recalculate the resulting MIDI value and will emit that change to the parameterMap. If that new MIDI value is different from the MIDI value currently stored in the parameterMap, the change will be propagated to all associated controls, messages sent and functions called. That is the reason why you get that recursion. Without that automated update the relationship between the display/MIDI values would not be consistent.

In a way I wish I could pass the valueObject as const to the function(), preventing making modifications to it, but I don’t think Lua supports that (for userdata data type).

Can you describe what you are trying to achieve? Changing the range of the value that I am currently changing sounds a bit spooky to me, but I totally get if I miss anything. Pls let me know.

1 Like

Thanks Martin.

I’m slowly learning the central unavoidable importance of the parametermap which has been more frequently lurking around the more I dig myself deeper and deeper into this hole. :slightly_smiling_face:

I’ll put something digestible together with some questions, thoughts and a preset just to clear some things up. Hopefully this evening…

1 Like

@martin Just noticed you use the following regexp when trying to match the input and output ports in the web editor.

/Electra.*Port 1/i

The problem with that is that it also matches “Electra Port 1 10” which in my case comes after “Electra Port 1” in the list of ports in chrome and therefore “Electra Port 1 10” gets pre-selected and I have change the port manually.

Maybe you could look into tightening up the regexp for in- and outports.

1 Like