Multiple struggle with LUA

:star_struck: :partying_face: :tada: !!
Thanks so mutch !!! It works

1 Like

Wow ! All this time i didn’t know it was able to do that … :joy::joy: .
Thanks ! I can now understand what is wrong with my LUA script !!..even thanks to you i already know ! :wink:
See you !!

1 Like

Regarding “how to make LUA cool for beginners” like me , I know it was an evoked subject , like exemple (that would be great into the editor) but i remember the time i was programming in Basic and what was really great is that i had under my eyes all the possible command i could use with basic .
what would be really usefull is having something like i discovered with Stability matrix .

There is a “prompt” completion inside the editor . translated to the E1 editor :
I could trigger it wih a “~” for exemple or a double space or a double ## … I don’t know a “HELP!! :joy:

Then when i type a “c” just after, the triggering word would erase and i have all the command “control” , in a list with all the “sub” function like
control:getId (
control:setVisible (
control:isVisible (

Or classic LUA command like
if i type a “l”
I would have :
local
load

I don’t know how complicated it can be to do that ? Between easy and really complex, my perception is around … certainly really not easy :joy::grin:

Thaaaaanks!! :wink:

Just to know ;).
Is it possible to make the E1 “store” that it has to monitor on port 2 ? because i have to “re enter” the
“syx 00h 21h 45h 14h 7Dh 01h 00h” on port 1 when i restart the E1 ?
Then something that could be part of the initialisation of the template ?
I ask because perhaps it’s already possible but i don’t know how to do it :joy:
If it’s not possible right now it’s not a problem i will just send, each time i restart the E1, the sysex message .
Thanks !!

I understood how to get the CC value of the curent control (the pad) but i don’t understand how to set the pad to 0 or 1 depending of other value than the “on”(127) or “off”(0) values .i also want to make it “on” or “off” on range of value (like “on” on a 127-120 and “off” on a 48-80) . But that would be easy with if/then since i understood how to put the pad state visualy “on” or “off” on the E1
Then i have

function LfoshapeCCval (valueObject, value)
    local message = valueObject:getMessage ()
    local CCval = message:getValue
    print ("Current value: " .. message:getValue ())
end

And it give me the CC . Now i need to set the state of the pad regarding some “uncommun” value. Then i need something like “setvalue” then i could give a 1.0 or 0.0 and put the pad on a “on” state or a “off” state . Is it possible ? I didn’t found a “setvalue”

I tried with message:setMax (43) regarding incomming CC value but it does not work . I would like to set arbitrarily the visual position of the Pad .

I’m facing a scenario where I have a VST parameter that determines an LFO shape, all controlled by the same CC. The values specify which shape is active: 0 for sine, 42 for square, 83 for S&H, and 127 for seq. Additionally, I have four pads on the E1 tied to this same CC, with the ‘on’ CC values being 0 for the first pad, 42 for the second, 83 for S&H, and 127 for the seq.

However, there’s a glitch in the VST. The square shape’s ‘on’ state is triggered at 43 when activated from the VST, but it requires a 42 to be sent from the E1 to turn it on – not 43. Therefore, I need to turn this square pad ‘on’ with a 42 (which is easy by setting the ‘on’ state to 42) sent from the E1, but also with a 43 received from the VST. And with a 43 the pad visual state is not “on”…

I haven’t found a way to override the visual state of the square pad on the E1 or to set the E1 to ‘on’ for a range of values (42-43). I’m starting to think this might not be possible. If it’s indeed impossible, I would appreciate someone confirming it? :pray: so I can stop searching for a solution.

As I’m not very advanced in LUA programming, I could really use some help. Thanks! :smile::partying_face:

It’s helpful if you can post a link to your current preset that is having problems.

It’s often easier to see the issue and suggest a solution that way.

of course , here it is :
https://app.electra.one/preset/leu8XvmiR9hLHdoqrOH6
There is nothing special regarding the template.
It’s on “obsession” page
The “square” pad.


Thanks !

Oh , i think i undestood something.
For example for a normal pad that receive CC, the pad is ON with a 127 value CC and OFF with a 0 value CC… But it is also OFF in all other value than the 127 … And as value properties for pad are 0.0 or 1.0 … then i supose it not possible to have ranged values to define “on” and “off” .
it seems that “off” is all other value than “on” ? Am i correct ?

Can someone confirm ?
If so, could it be possible in a futur update to have ranged value to define on and off ?? :see_no_evil: :grin:
Thanks for helping me !

I played around a bit this afternoon trying various solutions with no luck.

There are ways to do what you want, but it would take some extra coding.

Note that you can test the preset even if you don’t have the device attached by simply typing in the MIDI CC info at the bottom window of the MIDI log window.

1 Like

yes, it will be added to the editor. We are now busy with working on the new version, but I will have this added to the existing web editor too.

This is a more verbose example for a Pad. The setValue() is available for the message object, I just added it to the docs.

function normalizeValue(valueObject, value)
    local message = valueObject:getMessage ()
    local messageValue = message:getValue()
    local onMessageValue = message:getOnValue()
    local offMessageValue = message:getOffValue()

    if messageValue > 63 then
        message:setValue(onMessageValue)
    else
        message:setValue(offMessageValue)
    end
end

Play around with the example to see how it works. I think you should be able to resolve the 42-43 issues with that too.

Pls let me know if it helped to resolve your problem.

1 Like

Thanks a lot for your help !
first try to understand then apply your function …failure , error , not understanding why . i did that :grin:

function normalizeValue(valueObject, value)
local message = valueObject:getMessage ()
local messageValue = message:getValue()
local onMessageValue = message:getOnValue()
local offMessageValue = message:getOffValue()

if messageValue >= 42 or messageValue <= 43 then
message:setValue(onMessageValue)
else
message:setValue(offMessageValue)
end
end

The E1 crashes and i restarted , multiple time, trying variation… :joy: , now it is broken. it does not want to start anymore. I stay on the init window !!! beginning to follow the initialisation procedure…ohh myy… sorry E1…:joy::grin:

You might have a midi loop there - continuous switching 42 and 43 between the computer and the e1.

:tada: :star_struck: :tada: :star_struck: :partying_face: :tada: :star_struck: :tada: :partying_face:

This :

function normalizeValue(valueObject, value)
    local message = valueObject:getMessage ()
    local messageValue = message:getValue()
    local onMessageValue = message:getOnValue()
    local offMessageValue = message:getOffValue()
    print ("value" .. messageValue)
   if (messageValue == 42) then
     message:setValue(onMessageValue)
   end
end

Made the trick !!! Thank you both for helping me so mutch !! Obsession bug overdriven ! :grin:

For the storry…i made a lot of time to understand that “=” was not “==” :face_with_monocle::rofl:
The first say “this is the new value of the variable” and the other test its equality :star_struck:

1 Like

I love to see what is happening on the log LUA windows.
The script receive this 42 and the code say "nonono it’s a 43 ! …then “on” " !!!
yess!! magiiic ! :partying_face:

2 Likes