Multiple struggle with LUA

First , Why this script doesn’t work on PAD ?

function functionCallback (valueObject, value)
    local control = valueObject:getControl()

    if (value > 64) then

also this :

function Colorchange (valueObject, value)
local threshold = 64
if (value <= threshold) then

Does not work on Pad to . I seems that Pad are triggered only on Min and Max value . I am in a situation where i need pad to be triggered in a range value .

here is my situation :partying_face:
I have 4 pads with same CC . The first need to be triggered within 0-42, the second within 42-84 , the third within 85-120 and the last within 121-127 .
It works with min and max value between range
But the second Pad have to be triggered ON with the value 43 to…and as it does not trigger without strict values outside min and max value .
is there a way to do that ? I really struggle :rofl:

And also , how does i switch on or off pad on multiple custom values . Not only min and max ? with LUA … it’s so mutch LUA for me , i feel like i need a second brain :joy:

quick answer - maybe others can chime in with more. Tomorrow I can post some examples/solutions from some of my preset work.

Tip - put a “print()” statement in at the top of the function and have it print out the value: print("value = " .. value)

you might be surprised at the number of times it is called. Also - the value is typically 1.0 or 0.0 and you really need to look at the parameter value inside the function like this:

local pVal = valueObject:getMessage():getValue()

once you understand some of that, it may make your coding a bit easier. You can trigger the pad and then inside the function determine what to do based on the control ID or the parameter number

 local ctlId = valueObject:getControl():getId()
   local pNum = valueObject:getMessage():getParameterNumber()

Thanks for the tips !
I tried at the top of the function …then the E1 stop to execute scripts :joy:

function functionCallback (valueObject, value)
    print("value = " … value)
    local control = valueObject:getControl()

    if (value > 64) then

Then i understood that it was different and finally found that it was
print("value = " , value) ?
…still unsure but it seems that E1 execute script again .
But … where do i read this printed Value ???
nothing seems to get printed on the E1

Another question , how do i use the debugger ?
I tried to type print (“hello”) then enter …and nothing happen. My E1 is connected of course …
I don’t understand :rofl:

In a print command you need two points to concatenate.

1 Like

Sorry - in my haste I didn’t surround the examples with the code tags and the auto-correct changed 2 dots to 3. Edited my original.

If you open the web editor, at the top is the wrench and screwdriver crossed (hover tip says LUA and tools). You click on that to edit you LUA script.When you run the preset, at the bottom of that main screen you should see the debug print statements. If you need to see more than one or two lines, you can click on the bug icon on the top of the page. to see the entire screen.


Thanks for your help both !
But i am here :

And…How do i “run this preset” ??? :rofl:
I can send it to electra , i see nothing regarding runing this preset…On the debug side there is norhing to .
I sorry , it’s really dumb certainly but i don’t understand how you do that .
I was thinking like “when i send the preset to the E1 perhaps it happen something” but nothing seems to be printed when i switch my button .
I put the the function on my “Filter button”

Show a screenshot so we see where you’ve put the function on the Filter, please

1 Like

Yes !
On the right the Pad, on the middle he function associated to the Pad , on the right the function itself.

it’s a bit a weird name for a function, that is invoked and not a callback, but other than that, it looks okay at first sight.
When you send the preset to the electra one, while you keep the editor at the screen you show, don’t you see the ‘value’ messages appear in the area with the white circle in, every time you press the Filter pad?

1 Like

:open_mouth: ! Then the E1 editor have the ability to monitor in real time what is happening on the hardware controller ?!?!?!?!? !!!
That’s fantastic !! But no , nohing is displayed here (the white space) … In fact in never saw anything in this part of the editor .

I understand better how when you were talking about programming debuging etc how you were able to work :joy: . But why i don’t have this monitoring ?

When I debug I have the E1 connected via USB to my PC and simultaneously via DIN MIDI to the synths. So all these ‘print’ commands can then be shown within the preset editor.
What is your set up?

1 Like

I connect the E1 with USB . I use E1 editor on port 2, and Ableton midi com on port 1 . This way i can edit patch while i am connected to Ableton .
Then there is no “real time” com stuff with the editor on USB ?

oh , i think i understand . perhaps the port forwarding ? i gonna try
edit … i don’t find it … i thought there were somewhere, something that could send internally midi message from one port to another … but it seems not :no_mouth:

Oops, I haven’t done much myself on port forwarding. I fear I better not advise you on that part :laughing:

1 Like

I already thank you so mutch for your help !
Perhaps someone could help me resolve this mistery ? :face_with_monocle:

The log messages, ie. real time information about what E1 does as well as output of Lua print() command are transferred as SysEx messages on E1 one of the USB ports. By default, it is CTRL port (MIDI3 on windows). The definition of what port is used for logging is decoupled from the port that is used uploading presets. As you changed the ports, you are not able to see the log messages. I will adjust that in the editor.

For now, you can get it working by reconfiguring the log port with a SysEx message sent to E1. The message is:

F0h 00h 21h 45h 14h 7Dh nn 00h F7h

when nn is used to select the port

  • 0 = Port 1
  • 1 = Port 2
  • 2 = CTRL port

The SysEx message can be send using the MIDI console in the web app editor:

If you have editor using Port 2, the following MIDI console command should do the job:

syx 00h 21h 45h 14h 7Dh 01h 00h

Once the port is set up, the print commands will show up in the log window and the debugger. Also, the debugger can be used to observe data in Lua and call functions:

1 Like

the value parameter of the function callback represents the “display value” of the control, not the MIDI value. This can be translated to:

  • value for faders is a number that you see on the screen
  • value for pads is the state that you see on the screen (0 - off / 1 - on)
  • value for lists is an index of the selected item

as @oldgearguy correctly stated, if you want to retrieve the MIDI value of the assigned MIDI message, you do do it by querying the message object:

function padCallback(valueObject, value)
    -- print display value
    print("value " .. value)

    -- get and print message value
    local messageValue = valueObject:getMessage():getValue()
    print("message value " .. messageValue)