Set a specific value to a Control

It depends. Sometimes I am sending SysEx, sometimes also CC messages. Most of the controls I am using to change parameters on the instrument are working with CC messages for cutoff, AEG decay or amount of effects to name a few.

This is already working great. Let’s say that if the scene change sends for example a start value of 32 to the cutoff parameter for a certain sound. But the control for that particular device (part of the instrument, depending on the MIDI channel) has been used before for a different sound and value, so that it is still set to i.e. 46. The only thing I like to achieve is to set the control on that particular E1 page (which is related to the new scene) is automatically set to the start value of 32 so that it matches the value being sent with the scene change.

I know that I could also use parsing to get the current value from the instrument. But that is way too complicated for me and I also maybe like to start with a different value than the default one stored with the current patch on that part.

So again: If I could say: “Please set the control with the ID 1 to the value of 61” as I tried to get it with the script used in my post Set a specific value to a Control - #17 by HaPe I’d be totally fine. I really don’t need anything else. Hope it makes sense.

I should probably add that the whole E1 preset is designed for a kind of synth jam, meaning I only use it from page 1 to page x - left to right - and never go back. So a lot of the exact same controls appear multiple times on different pages, where I use them once and then move on to the next scene, which might even call up a different sound.

One last question - some screens have more than one scene in them. You can touch a control in another scene without changing the scene.

Is that ok?

Yes I could touch or use a control of the next scene within a page but I won’t do it. Some scenes don’t need much controls so I combined them on a single page.

But I just hope you don’t think too far and with too much effort. I created a small preset just to test this sending a default value to a control like this…

https://app.electra.one/preset/gJXaLrSNGbZOwqAbVDoj

I assigned a momentary pad to a function but it doesn’t work. Probably my formatting isn’t correct. Maybe you can just look at this example and - please correct me if I’m wrong - i think if this pad works using the function I could also trigger it with the scene change. Thanks.

See if this version works the same as yours.
(hopefully also sets the defaults properly)

SEQTRAK test

1 Like

Thank you so much @oldgearguy. I will definitely check it tomorrow. Today it’s too late here because tomorrow starts early. :sleeping:
Thanks again, I’ll let you know how it went.

I just tried it and unfortunately it doesn’t seem to work on my E1.

To be sure nothing external might disturb I even disconnected SEQTRAK from the E1 and just did a “blind” test. Which still works with my - of course wrong - approach using “parameterMap”, no matter if the instrument is connected or not. I even tried to copy your script to the small test project I created and assigned it to a function but also couldn’t get it to work.

I really wish I could have just let you know that it worked. :man_shrugging:t3: So sorry…

What do you mean does not work at all?
So it does not send any MIDI data out to the SEQTRAK or the data it sends does not do the right thing?

I clearly see MIDI data being generated in the debug window, so I am a bit confused.
Does it load cleanly into the Electra One?

Do you have a Mk I or the newer Mk II Electra One? (not that the preset is super big or uses anything fancy - just want to know for my testing).

I changed some of the screen controls, so you cannot just take the Lua script and paste it into your preset. You need all of it - either my version or yours - they cannot be mixed.

I have been following ( always learning with examples)

YES :wink: I have it running on my MK I and can see MIDI being generated.

Thanks a lot for your reply. Apologies that I didn’t provide more detail. But I was just focusing on the E1 control ID31 which didn’t change its value with the scene change to scene 4.

As mentioned earlier my main goal is to set the E1 control to a dedicated value, not to send MIDI. If both can happen in one command it would save me some work. But sending values with the scene change is something I already do quite often in this preset.

Your preset is loading fine and it sends MIDI.

From your script line:

“valueId:setDefault(32)”

I was expecting that it should set a new default value to the E1 control with the ID 31. But I figured out that it doesn’t do that and not even send the value of 32 via MIDI.

It took me quite a while to figure out what it really does but it is kind of logical to me when reading:

“local ctlId = controls.get(31)”

Indeed it gets the current value from control 31 and sends this value via MIDI with the scene change. So if the current value of that particular control is set to 60 it sends exactly this value.

Because maybe my English is not good enough to describe my goal I decided to shoot a video which I will send by PN. Even though I need to use the same pretty bad English there :joy: it might help to visually communicate what the current status is and what I like to achieve.

I hope this helps. But please: if you are busy with other things or this is too much effort on top of what you already had, please just let me know. I will maybe find my workaround, sooner or later.

Thanks again!

1 Like

when you get a chance, take a look at my version again.
I made the adjustment for resetting the controls every time you go to a scene.

NOTE NOTE - I only have it implemented for the Filter Cutoff so far.

I can do the other controls, but I need to type in a long explanation of how all the pieces (control ID, parameter number, message type, parameter map) interact.

Once I do that, hopefully the code will become more clear.

1 Like

Thank you so much @oldgearguy. You are again my hero! It now works as I like to have it.

To hopefully save you some time to explain what you did I investigated a bit on my own. I figured out that you started the entire script with:

deviceId = 9
device= devices.get(deviceId)
devPort = device:getPort ()
devChannel = device:getChannel ()

You then changed the control types from the assigned parameter number (i.e. CC74) to “Virtual”. Since the controls were already assigned to functions (once also realized with your kind help) you added the definition of each virtual controller to its dedicated parameter.

if (ctrlId == 67) then
midi.sendControlChange(PORT_1, 8, 74, value)
end

Within the scene you implemented:

local ctlId = controls.get(31)
local valueId = ctlId:getValue(“value”)
valueId:setDefault(32)
parameterMap.set(deviceId, PT_VIRTUAL, 31, 32)

… which looks to me like a combination of “setDefault” and “parameterMap.set” because it doesn’t work without it.

With my understanding so far I was even able to apply this to the value “Decay (CC75)” for control ID 32.

One important open question to me is how to apply this technique to more than device (and MIDI CH) No. 9. I recognized that you applied the same thing for parameter ID 67. But this was initially assigned to SY1 (device and MIDI CH 8) and currently it just seem to work if assigned to device No. 9.

If I didn’t get something completely wrong I still wonder why this has to be that complex. I still wonder why there is obviously no simple command that says: Please set control with the ID x to the default value y - independent from what the control does, what parameter is assigned to it and what kind of message it sends. Is this really such a “weird” idea or rare case?

Anyway if you could maybe just confirm what I got so far and then let me know if this approach is realizable for more than one device at the same time it would be awesome. Thanks again!

You mostly have it correct. I will try to fill in the gaps later today after work.

Note that I have been trying to solve your problems using your code and trying to keep it the way you designed it.
If you want to see “how I would do it”, that is something different.

Now that I see your screens and what you want to do, there are many ways to solve the problem, some simpler than others.

| HaPe
August 6 |

  • | - |

Thank you so much @oldgearguy. You are again my hero! It now works as I like to have it.

To hopefully save you some time to explain what you did I investigated a bit on my own. I figured out that you started the entire script with:

deviceId = 9
device= devices.get(deviceId)
devPort = device:getPort ()
devChannel = device:getChannel ()

You then changed the control types from the assigned parameter number (i.e. CC74) to “Virtual”. Since the controls were already assigned to functions (once also realized with your kind help) you added the definition of each virtual controller to its dedicated parameter.

if (ctrlId == 67) then
midi.sendControlChange(PORT_1, 8, 74, value)
end

Within the scene you implemented:

local ctlId = controls.get(31)
local valueId = ctlId:getValue(“value”)
valueId:setDefault(32)
parameterMap.set(deviceId, PT_VIRTUAL, 31, 32)

… which looks to me like a combination of “setDefault” and “parameterMap.set” because it doesn’t work without it.

With my understanding so far I was even able to apply this to the value “Decay (CC75)” for control ID 32.

One important open question to me is how to apply this technique to more than device (and MIDI CH) No. 9. I recognized that you applied the same thing for parameter ID 67. But this was initially assigned to SY1 (device and MIDI CH 8) and currently it just seem to work if assigned to device No. 9.

If I didn’t get something completely wrong I still wonder why this has to be that complex. I still wonder why there is obviously no simple command that says: Please set control with the ID x to the default value y - independent from what the control does, what parameter is assigned to it and what kind of message it sends. Is this really such a “weird” idea or rare case?

Anyway if you could maybe just confirm what I got so far and then let me know if this approach is realizable for more than one device at the same time it would be awesome. Thanks again!

Thanks again. Sounds great. My problem is that I am not able to get why the scripts contain all these “get’s”.

I probably misinterpreted them since I think the script needs to get this information from the source (= the preset) to the script (= the destination). But if so, why?

To my understanding all these “get…” devices, ports, channels etc. ask for information that is already fixed. A control is already assigned to:

• a dedicated port
• a dedicated device (separate device using a single channel, or instrument’s part and MIDI channel)
• a dedicated (and unique) ID

If my goal would be to change some of these pre-defined settings I’d get the idea of “getting…” but my simple approach would be a one way communication as already written.

Please enlighten me a bit if I’m (probably) wrong with this kind of understanding. Thanks.

Looking over my example, there’s some wrong numbering/parameter values in there.

However, the Electra One OS is an object oriented approach to increase flexibility, reduce code duplication, and make memory use more dynamic and need less memory. If everything was directly addressed from the control, there would be a lot of wasted space carrying around variables that were never used or changed.

So, to get the the MIDI level, you usually need to go from the control to the value to the message. The on-line documentation is good at explaining a lot of that.

In addition, a control can have a minimum, maximum, and default and these can be changed dynamically. In addition, the MIDI value range can be changed and the Electra will try to re-scale them based on the control information.

Basically, all the flexibility means sometimes you need to do a bit more to get to certain levels.
Changing a display or a default or sending a MIDI message doesn’t not automatically mean everything else gets updated with the same information.

1 Like

I copied the example again but couldn’t find any difference in the lua script. You didn’t change something there, did you?

Thanks for all the explantation. Probably one must have a special DNA for this kind of thinking which I obviously don’t have.

It starts with this first line…

… which refers to device 9 but some of the controls are assigned to device 8 and it works also.

Anyway, thanks again for all your help. It’s helping me move forward with this little project. If I ever get a chance to record a jam using this preset, I’ll give you credits. Unfortunately, that seems to be the only thing I can give back for your effort. :man_shrugging:t3:

Think of it this way – using the web UI to create the controls and define the CC number or sysex string to use, all the controls follow the rules defined by the device ID/Electra Port/MIDI channel.

Inside the Lua scripts, you can talk to anyone and everyone as long as you use the correct identifiers.
So you can have one line of Lua sending a CC message to Electra Port 1, MIDI channel 6, CC number 74 and
the next line of Lua can send a CC message to Port 2, MIDI channel 2, CC number 7 and
the next line can send a sysex message to port 1, and so on.

I know it is slower and not doing anything “useful”, but it is very helpful to create a very small preset with only 1 or 2 controls and play around with all the things like device, port, channel and such with a lot of print() statements in the Lua code to show you what is being done and in what order. You can also look at the MIDI debug screen to see the MIDI commands being generated and all of that should help explain what is going on.

These discussions are the things you can learn more quickly if you were sitting right next to someone and you watched and asked questions as changes are made.
Unfortunately, that is very hard to do, so creating small test cases is one way to gain understanding.
Just copying a large chunk of someone’s script is useful as long as you understand what it is doing. Since the Electra One has both the GUI controls and definitions and possibly Lua code, both pieces are necessary sometimes to make things work as intended.

| HaPe
August 7 |

  • | - |

oldgearguy:

Looking over my example, there’s some wrong numbering/parameter values in there.

I copied the example again but couldn’t find any difference in the lua script. You didn’t change something there, did you?

oldgearguy:

Basically, all the flexibility means sometimes you need to do a bit more to get to certain levels.
Changing a display or a default or sending a MIDI message doesn’t not automatically mean everything else gets updated with the same information.

Thanks for all the explantation. Probably one must have a special DNA for this kind of thinking which I obviously don’t have.

It starts with this first line…

oldgearguy:

deviceId = 9

… which refers to device 9 but some of the controls are assigned to device 8 and it works also.

Anyway, thanks again for all your help. It’s helping me move forward with this little project. If I ever get a chance to record a jam using this preset, I’ll give you credits. Unfortunately, that seems to be the only thing I can give back for your effort. :man_shrugging:t3:

1 Like